[Rails] Not work has_many :through association
Not work has_many :through association in rails 2.3.5
Models:
class Role < ActiveRecord::Base
attr_accessible :name
has_many :assignments
has_many :users, :through => :assignments
end
class User < ActiveRecord::Base
attr_accessible :name
has_many :assignments
has_many :roles, :through => :assignments
end
class Assignment < ActiveRecord::Base
belongs_to :user
belongs_to :role
end
In the view form of user
- for user in User.all
= check_box_tag 'role[user_ids][]', user.id, @role.users.include?
(user)
=h user.name
When I create a new user, nothing happens, the array of user_ids is
empty
--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home