Hi there!
I have the following classes, but I don''t undersant why, when I try to
create some
class Wishlist < ActiveRecord::Base
has_many :activated_user_wishlists, :class_name =>
"UserWishlist",
:conditions => {:registered => true}
has_many :users_registered, :through => :activated_user_wishlists,
:class_name => "User", :source => "wishlist"
end
class UserWishlist < ActiveRecord::Base
belongs_to :wishlist
belongs_to :user
end
class User < ActiveRecord::Base
has_many :user_wishlists
has_many :wishlists, :through => :user_wishlists
end
And when I try to do that:
Wishlist.first.users_registered << User.first
And then look at the join table, that''s what I see:
#<UserWishlist user_id: nil, wishlist_id: 1, admin: false, registered:
true>]
Someone know why user_id is nil?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.