im trying to make a view that is a master detail and am just stumped. I should be able to iterate through system.prices right to render all the pric info from the prices model? Help is appreciated.. Sam Models class Price < ActiveRecord::Base belongs_to :system end class System < ActiveRecord::Base belongs_to :company has_many :prices end list in the system_controller def list @systems = System.find(:all) end and the layout <h1>Listing systems</h1> <table> <tr> <th>ID</th> <th>Company</th> <th>Model</th> <th>SID</th> <th>CPU</th> <th>URL</th> <th colspan = "3" >Action</th> </tr> <% for system in @systems %> <tr> <td><%= system.id %></td> <td><%= system.company.name %></td> <td><%= system.model %></td> <td><%= system.sid %></td> <td><%= system.cpu %></td> <td><%= system.murl %></td> <td><%= link_to ''Show'', :action => ''show'', :id => system %></td> <td><%= link_to ''Edit'', :action => ''edit'', :id => system %></td> <td><%= link_to ''Destroy'', {:action => ''destroy'', :id => system}, :confirm => ''Are you sure?'' %></td> </tr> <% for price in @system.prices %> <tr> <td><%= price.price %></td> <td><%= price.store_name %></td> <td><%= price.img_source %></td> <td colspan="6"></td> </tr> <% end %> <% end %> </table> <br /> <%= link_to ''New system'', :action => ''new'' %>
On Aug 6, 2005, at 3:26 PM, Sam Mayes wrote:> <% for price in @system.prices %> > <tr> > <td><%= price.price %></td> > <td><%= price.store_name %></td> > <td><%= price.img_source %></td> > <td colspan="6"></td> > </tr> > <% end %>Shouldn''t that be "for price in system.prices"? Regards, Ed -- Transmogrify, LLC * <xmog.com>
I thought so too and i get this undefined method `prices'' for System:Class /app/controllers/systems_controller.rb:9:in `list'' script/server:49 On 8/6/05, Ed Watkeys <edw-tIV1OJqwIcc@public.gmane.org> wrote:> > On Aug 6, 2005, at 3:26 PM, Sam Mayes wrote: > > > <% for price in @system.prices %> > > <tr> > > <td><%= price.price %></td> > > <td><%= price.store_name %></td> > > <td><%= price.img_source %></td> > > <td colspan="6"></td> > > </tr> > > <% end %> > > Shouldn''t that be "for price in system.prices"? > > Regards, > Ed > > -- > Transmogrify, LLC * <xmog.com> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > lists.rubyonrails.org/mailman/listinfo/rails >
Thanks Ed. Jeez that and one type blows everything up :) Ive definately been staring at this too long. DUH Sam On 8/6/05, Sam Mayes <codeslave-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I thought so too and i get this > > undefined method `prices'' for System:Class > > /app/controllers/systems_controller.rb:9:in `list'' > script/server:49 > > > > On 8/6/05, Ed Watkeys <edw-tIV1OJqwIcc@public.gmane.org> wrote: > > > > On Aug 6, 2005, at 3:26 PM, Sam Mayes wrote: > > > > > <% for price in @system.prices %> > > > <tr> > > > <td><%= price.price %></td> > > > <td><%= price.store_name %></td> > > > <td><%= price.img_source %></td> > > > <td colspan="6"></td> > > > </tr> > > > <% end %> > > > > Shouldn''t that be "for price in system.prices"? > > > > Regards, > > Ed > > > > -- > > Transmogrify, LLC * <xmog.com> > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > lists.rubyonrails.org/mailman/listinfo/rails > > >
On Aug 6, 2005, at 3:33 PM, Sam Mayes wrote:> I thought so too and i get this > > undefined method `prices'' for System:ClassHave you tried changing the name of the variable ''system''? Aside from my DB session hell, I was bitten by a new ActionView method named ''tag'' when moving from 0.12 to 0.13. Maybe it''s time to put an underscore or three in front of every local variable. Regards, Ed -- Transmogrify, LLC * <xmog.com>