Forum: Ruby on Rails has_many :through, form for join model attributes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D26ab4f98a07ce0fb893c828d6d8d7c6?d=identicon&s=25 Dylan Markow (Guest)
on 2006-05-03 18:56
(Received via mailing list)
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 %>
E9207864177d1f58537592fdb6a41219?d=identicon&s=25 Hans (Guest)
on 2007-06-26 13:27
Hi Dylan

Did you ever find a solution for this problem?
This topic is locked and can not be replied to.