Hi, I think I''m doing this the right way, but can''t get it going. I''m building a menu from the values in a mySQL table, and want to build it on the fly. This is something that should be working but only works halfway: <% @pages = Page.find(:all, :conditions => [''site_id = 4'']) %> <% @pages.each do |p| %> xyz <%p.id%> <% end %> I know there are two page objects in the array, and the literal in the loop indeed paints twice, but I can''t get p.id to paint anything at all though. -- Posted via http://www.ruby-forum.com/.
Joe Cairns wrote:> Hi, I think I''m doing this the right way, but can''t get it going. I''m > building a menu from the values in a mySQL table, and want to build it > on the fly. This is something that should be working but only works > halfway: > > <% @pages = Page.find(:all, :conditions => [''site_id = 4'']) %> > <% @pages.each do |p| %> > xyz > <%p.id%> > <% end %> > > > I know there are two page objects in the array, and the literal in the > loop indeed paints twice, but I can''t get p.id to paint anything at all > though.You need an = in Rails tags you want displayed. :) i.e. <%= p.id %> -- Posted via http://www.ruby-forum.com/.
Adam Bloom wrote:> Joe Cairns wrote: >> Hi, I think I''m doing this the right way, but can''t get it going. I''m >> building a menu from the values in a mySQL table, and want to build it >> on the fly. This is something that should be working but only works >> halfway: >> >> <% @pages = Page.find(:all, :conditions => [''site_id = 4'']) %> >> <% @pages.each do |p| %> >> xyz >> <%p.id%> >> <% end %> >> >> >> I know there are two page objects in the array, and the literal in the >> loop indeed paints twice, but I can''t get p.id to paint anything at all >> though. > > You need an = in Rails tags you want displayed. :) > > i.e. <%= p.id %>Ok thanks, that worked! Sorry for the stupid question, but I''m up to my nose in learning curve. -- Posted via http://www.ruby-forum.com/.
>> You need an = in Rails tags you want displayed. :) >> >> i.e. <%= p.id %> > > Ok thanks, that worked! Sorry for the stupid question, but I''m up to my > nose in learning curve.It''s only stupid the first few times you do it. By the time you''ve done it as many times as me, it''s bang-your-head-against-a-wall-dumb. :D -Adam -- Posted via http://www.ruby-forum.com/.