Skip to content

Instantly share code, notes, and snippets.

@soulnafein
Created January 6, 2011 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soulnafein/767908 to your computer and use it in GitHub Desktop.
Save soulnafein/767908 to your computer and use it in GitHub Desktop.
#Just a note, Event has 2 associations
has_many :attendances
has_many :attendees, :through => :attendances, :source => :user
#Irb session that shows the problem
Loading development environment (Rails 3.0.3)
ruby-1.8.7-p302 > u = User.new
=> #<User id: nil, full_name: nil, tagline: nil, bio: nil, location: nil, company: nil, job_title: nil, website: nil, twitter_username: nil, linkedin_profile: nil, github_account: nil, created_at: nil, updated_at: nil, interests: nil, email: nil, phone_number: nil, blog_feed: nil, username: nil, crypted_password: nil, password_salt: nil, persistence_token: nil, active: nil, perishable_token: nil, agreed_tc_and_pp: false, bitbucket_account: nil, delicious_username: nil, country: nil, city: nil>
ruby-1.8.7-p302 > u.id = 42
=> 42
ruby-1.8.7-p302 > e = Event.new
=> #<Event id: nil, title: nil, city: nil, country: nil, description: nil, link: nil, created_at: nil, updated_at: nil, date: nil, group_id: nil, disabled: false>
ruby-1.8.7-p302 > an_array = []
=> []
ruby-1.8.7-p302 > an_array.push(u); e.attendees.push(u)
=> [#<User id: 42, full_name: nil, tagline: nil, bio: nil, location: nil, company: nil, job_title: nil, website: nil, twitter_username: nil, linkedin_profile: nil, github_account: nil, created_at: nil, updated_at: nil, interests: nil, email: nil, phone_number: nil, blog_feed: nil, username: nil, crypted_password: nil, password_salt: nil, persistence_token: nil, active: nil, perishable_token: nil, agreed_tc_and_pp: false, bitbucket_account: nil, delicious_username: nil, country: nil, city: nil>]
ruby-1.8.7-p302 > an_array.include?(u)
=> true
ruby-1.8.7-p302 > e.attendees.include?(u)
=> false <------ WHAT THE FUCK?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment