Dylan Markow
2006-Apr-30 22:48 UTC
[Rails] has_many :through, form for join model attributes
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| %>
<tr>
<td>Client:<br/>
<%= link_to ''(edit info)'', :controller =>
''clients'', :action
=> ''edit'', :id => c.id %><br/>
</td>
<td>
<%= "#{client.display_name}<br/>" %>
<%= THIS IS WHERE I WANT A TEXT FIELD TO UPDATE EACH CLIENT''S
FILE NUMBER %>
</td>
</tr>
<% end %>
Hi Dylan Did you ever find a solution for this problem? -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---