Hi... I have list.rhtml file default generated by scaffold for user table. This file displays list of all user table rows. Inside this file I want to display the list of the all the rows from my anothe table (stores). How to do that? I tried with following inside my above list.rhtml. ================== <% for store in @stores %> <tr> <% for column in Store.content_columns %> <td><%=h store.send(column.name) %></td> <% end %> <td></td> </tr> <% end %> ================== But its giving me error like:- =============== You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occured while evaluating nil.each =============== I think I am getting above error because list.rhtml file is in user view & not in store view . How to fix above error ?
on 2006-04-05 12:08
on 2006-04-05 12:13
Prashant Tiwari wrote: > Hi... > > I have list.rhtml file default generated by scaffold for user table. > This file displays list of all user table rows. Inside this file I want > to display the list of the all the rows from my anothe table (stores). > How to do that? You need to populate the @stores variable before using it. If you look in UserController#list you'll see how @users is populated. If you go to the UserController#list method, add @stores = Store.find(:all) Variables are created in the controller and then accessed in the view. Alan