i don''t know how to access to the collecction of data that exists in other model. for example i generate two scaffold : company and employe both have a controller, a model and 5 files in the views: _form.rhtml, list.rhtml, new.rhtml, edit.rhtml and show.rhtml the views are working very well, but each access just one table: company or employe my problem is any simple, but i can''t do it in the views that show the list of the employes i want to show the list of companies resume: in the same page show both list. help! please -- Posted via http://www.ruby-forum.com/.
X-1101 wrote:> i don''t know how to access to the collecction of data that exists in > other model. > > for example > i generate two scaffold : company and employe > > both have a controller, a model and 5 files in the views: > _form.rhtml, list.rhtml, new.rhtml, edit.rhtml and show.rhtml > > > the views are working very well, but each access just one table: company > or employe > > > my problem is any simple, but i can''t do it > > in the views that show the list of the employes i want to show the list > of companies > > resume: > in the same page show both list. > > help! > please#Controller def list @employees = Employees.find(:all) @companies = Company.find(:all) end #View list.rhtml <h2>Employees</h2> <% for employee in @employees %> <%= employee.name %><br /> <% end %> <h2>Companies</h2> <% for company in @companies %> <%= company.name %> has <%= company.employees.size %> employees.<br /> <% end %> -- Posted via http://www.ruby-forum.com/.