Hi,
I’ve been breaking my head over this thing with no success. Here is my
table layout -
class User < AR
has_many :memberships
has_many :groups, :through => :memberships
…
class Group < AR
has_many :memberships
has_many :users, :through => :memberships
…
class Membership < AR
belongs_to :user, :class_name => “User”, :foreign_key => “user_id”
belongs_to :group, :class_name => “Group”, :foreign_key =>
“Group_id”
…
Now, Membership table has an extra field called membership_id and I
want the user to fill in that id in the edit form.
My view looks like this. The checkbox fields works great and I can
update my db pretty well (barring minor issues).
<% form_for :user, @user, :url => { :action => ‘save_memberships’} do |
form| %>
<%= form.error_messages %>
<% @groups.each do |g| %>
<%= check_box_tag(“user[membership_ids][]”, g.id,
@user.groups.include?(g)) %>
<%= “#{g.name}”%>
----> I have to invoke my partial to collect membership id here. But
can’t get the call right. The partial is below.
<% end%>
<% end%>
This is the membership partial -
Any ideas how I can do this?
thanks