problem about has-many-through-Record and share programming errors


  • Harish Shetty
    ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1 has-many has-many-through
    My goal here is to print list of users from specified city and category with their names, address and club name.Name and address display correctly but when i add club name,says undefined method memberships for #.I know this is because Club is in different model ,So the question is how do i access club nam

  • JLBaguio
    ruby-on-rails-3 devise has-many-through friend user-profile
    I want a User(x) to be able to add another User(y) as a friend while User(x) is on User(y’s) Profile Page. I set up a has_many_through and everything works except that I can only add a friend from the User Index View. Thank you in advance…The code is below:Also:I wanted to place the “friend” link on the view/profile/show.html.erb. When I added @users = User.all to the existing profiles_controller.rb I received the error – undefined method friendships’ for nil:NilClass. When I replaced @user = User.find(params[:id]) with @users = User.all I received the error – NoMethodError in Profiles#show… undefined methodinverse_friends’ for nil:NilClassThe Code that works in UserIndexView but not ProfileShowView:% for user in @users %>

    user), :method => :post%>

    The following error occurs:NoMethodError in Profiles#showShowing /Users/mgoff1/LOAP_1.2.2/app/views/profiles/show.html.erb where line #13 raised: undefined method `each’ for nil:NilClass Extracted source (around line #13): 10: 11: 12: 13: 14: 15:

    16: :group_contacts, :conditions => {:groups => {:published => true}} endproblem happens when I try to instantiate a group from


  • jmorrissette
    forms devise ruby-on-rails-3.2 has-many-through
    This would seem easy to do, basically I’m using Devise for administrative purposes, so every user signing up can create a product/figure linked to their account then put up that product for a trade with another user.Class Userrolify:recoverable, :rememberable, :trackable, :validatableattr_accessible :role_ids, :as => :adminattr_accessible :email, :password, :password_confirmation, :remember_

  • Paul
    ruby-on-rails has-many-through acts-as-list
    I am having an issue updating a has_many through record. Here is my setup:class TastingGroup < ActiveRecord::Basehas_many :group_winehas_many :wines, through: :group_wine endclass GroupWine < ActiveRecord::Basebelongs_to :tasting_groupbelongs_to :wine endclass W

  • Nathan Couch
    ruby-on-rails-3 foreign-keys has-many-through belongs-to nesting
    This is my first post here and to be honest, I don’t tend to ask many questions, but something has been irritating me for quite some time involving nesting in Ruby on Rails.I have a class Thought (which are members’ individual posts) that are paginated as @share_items. I am including a like button that will allow members to like other members’ posts (like Facebook). The like button has the class Opinion.My code thus far:Class Member has_many :thoughts, dependent: :destroy has_many :opinions, foreign_key: “fan_id”, dependent: :destroy has_many :fans, through: :opinionsClass Thought belongs_to :memberhas_many :opinions, foreign_key: “like_id”, dependent: :destroy has_many :likes, through: :opinionsvalidates :member_id, presence: trueClass Opinion attr_accessible :like_idbelongs_to :fan, class_name: “Member” belongs_to :like, class_name: “Thought”validates :fan_id, presence: true validates :like_id, presence: trueMember Model def share Thought.from_members_authenticated(self) endMemberPages Controller def homepage @share_items = registered_member.share.paginate(page:

  • daiikota
    ruby activerecord has-many-through mysql2
    I ran into a little problem I have a has_many through relationship here is the code for the modelsclass User < ActiveRecord::Basehas_many :friendshipshas_many :followings, :through => :friendships, :foreign_key => “followed_id” endclass Friendship < ActiveRecord::Basebelongs_to :user belongs_to :following, :class_name => “User”, :

  • sandovalg
    ruby ruby-on-rails-3.2 associations has-many-through nomethoderror
    I am encountering a problem when trying to .build a new appointment. But first a look at my Model(s)class Patient < ActiveRecord::Baseattr_accessible :address1, :address2, :city, :comment, :email, :first_name, :init_date, :init_time, :last_name, :mobile, :notes, :phone, :state, :zipbefore_validation :upcase_patientbefore_save { self.email.downcase! }has_many :appointments, dependent: :destroyhas_many :procedures, through: :appointmentsclass Procedure < ActiveRecord::Baseattr_accessible :comment, :occurence, :procedure, :procedure_code, :procedure_price, :procedure_time, :visitsbefore_validation :uppercase_procedurehas_many :appointmentshas_many :patients, through: :appointmentsclass Appointment < ActiveRecord::Baseattr_accessible :appointment_date, :appointment_notes, :appointment_time, :procedure_idbelongs_to :patientbelongs_to :procedureclass AppointmentsController < ApplicationController include PatientsHelper before_filter :signed_in_userdef create@patient = current_patient@appointment = @patient.appointments.build(params[:appointment])if @appointment.saveflash[:success] = “Appointment scheduled!”redirect_to patient_path(@patient)elserender patient_path(@patient)end endmodule PatientsHelperdef current_patient=(patient)@current_patient = patientenddef current_patient@current_patientenddef current_patient?(patient)patient == current_pat

  • tvalent2
    ruby-on-rails-3 has-many-through nameerror
    I’m new to Rails and am following Railscast #258 to implement jQuery TokenInput, and for some reason in trying to create a new record I’m getting the error:NameError: undefined local variable or method `through’ for #from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.5/lib/active_record/base.rb:1008:in `method_missing’from /Users/Travis/Desktop/YourTurn/app/models/tag.rb:4from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:454:in `load’from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:454:in `lo

  • brad
    ruby-on-rails activerecord has-many-through
    This kind of goes along with my original question about has_many :through with conditions, but I’ve found another problem.Given this class:class Contact < ARhas_many :group_contactshas_many :groups, :through => :group_contacts, :conditions => {:published => true}has_many :anonymous_groups, :through => :group_contacts, :source => :group, :conditions => {:anonymous => true} endMy problem happens wh

  • keruilin
    mysql ruby-on-rails has-many-through belongs-to
    Here’s my User model:class User < ActiveRecord::Basehas_many :friends, :class_name => ‘Friendship’, :dependent => :destroyendHere’s my Friendship model:class Friendship < ActiveRecord::Bas

  • vrish88
    ruby-on-rails has-many-through
    I have a model, Feed, that has and belongs to many FilteredUsers. In this case I have implemented it through a has_many :through relationship.class Feed < ActiveRecord::Basehas_many :denials, :depend

  • Adgezaza
    ruby-on-rails has-many-through
    I have a has_many and has_many :through relationship that looks like this…class Guestlist < ActiveRecord::Basebelongs_to :venueshas_many :patronshas_many :users, :through => :patronsattr_accessible :capacity, :end_time, :name, :start_time,

  • user506706
    ruby-on-rails query has-many-through
    I’m using Rails 2.3 and I have 3 tables, which manages user permissions to buildings. The mygroups table is the list of groups users and buildings belong to. The mygroupsbuildings is the list of buildings with their associated group. The mygroupsusers is the list of users with their associated group.create_table “mygroups”, :force => true do |t|t.string “name”t.integer “user_id”t.string “user_name”t.integer “permissions” endcreate_table “mygroupbuildings”, :force => true do |t|t.integer “mygroup_id”t.integer “building_id” endcreate

  • unlikely_monkey
    ruby-on-rails-3 activerecord has-many-through
    I have three models:Class Project < ActiveRecord::Basehas_many :taskshas_many :tags, :through => :tasks endClass Tasks < ActiveRecord::Basebelongs_to :projecthas_and_belongs_to_many :tags endClass Tags < ActiveRecord::Ba

  • kitensei
    ruby-on-rails activerecord has-many-through
    I have the following structure:class Product < ActiveRecord::Basehas_many :product_unitshas_many :units, :through => :product_units, :foreign_key => :unitID endclass Unit < ActiveRecord::Basehas_many :product_unitshas_many :products, :through => :produc

  • cmd
    ruby-on-rails ruby-on-rails-3 nested-forms has-many-through
    I have a has many through relationship between my user and a vehicle.User has many Ownerships User has many vehicles through Ownerships.Ownerships belongs to User and VehicleVehicle has many Ownerships Vehicle has many Users through OwnershipsOn the vehicle show page I would like t

Originally posted 2013-08-31 07:48:17.