Has_many :through, form for join model attributes


#1

I have the following schema:

class ClientsProject < ActiveRecord::Base
belongs_to :client
belongs_to :project
end

class Client < ActiveRecord::Base
has_many :clients_projects
has_many :projects, :through => :clients_projects
end

class Project < ActiveRecord::Base
has_many :clients_projects
has_many :clients, :through => :clients_projects
end

I have a form to show the Project model. This form lists each
client’s name and contact information. I would also like to list the
client’s file_number for this project. File_number is a column in my
clients_projects table. I would like to insert a field to access and
edit each client’s file number in this form, but I don’t know how to
go about it:

<% @clients.each do |c| %>

Client:
<%= link_to '(edit info)', :controller => 'clients', :action => 'edit', :id => c.id %>
<%= "#{client.display_name}
" %> <%= THIS IS WHERE I WANT A TEXT FIELD TO UPDATE EACH CLIENT'S FILE NUMBER %> <% end %>

#2

Hi Dylan

Did you ever find a solution for this problem?