<% for product in @products %> <%= h(product.description) %> It is simple code I see, but it has no umm classes I think <% for product <-- that can be fish in @products <-- this is the table I know %> <%= h(product <-- so this can be fish as well .description<-- this is the object to show the table field) %> But what would <% for() _ in @() %> be called.. Sorry if this is confusing -- Posted via http://www.ruby-forum.com/.
Yes, it is confusing...but I''ll give it a try. You''re talking about loops. Since these are part of the Ruby language and not Rails you''ll find information about them in the ruby-doc.org Looking at your example I think you might want to try: <% @products.each do |product| %> <%= h(product.description) %> <% end %> ''product'' in this case can be anything...fish, or potatos, or whatever as long as it has the method called description you''ll be good to go. If you want to find out what kind of object product is (assuming you have an mixed array of different types of objects) <%= h(product.class) %> AND if you want to really get crazy you can look at the class of the object in your array and render different partials for each class -Brian On 6/30/06, trip dragon <colo0logo@gmail.com> wrote:> > <% for product in @products %> > <%= h(product.description) %> > > It is simple code I see, but it has no umm classes I think > > <% for product <-- that can be fish in @products <-- this is the table > I know %> > > > <%= h(product <-- so this can be fish as well .description<-- > this is the object to show the table field) %> > > But what would <% for() _ in @() %> be called.. Sorry if this is > confusing > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060630/0a943704/attachment.html
Brian Chamberlain wrote:> Yes, it is confusing...but I''ll give it a try. > > You''re talking about loops. Since these are part of the Ruby language > and > not Rails you''ll find information about them in the ruby-doc.org > > Looking at your example I think you might want to try: > <% @products.each do |product| %> > <%= h(product.description) %> > <% end %> > > ''product'' in this case can be anything...fish, or potatos, or whatever > as > long as it has the method called description you''ll be good to go. > If you want to find out what kind of object product is (assuming you > have an > mixed array of different types of objects) > <%= h(product.class) %> > AND if you want to really get crazy you can look at the class of the > object > in your array and render different partials for each class > > -BrianYikes,,,, Everyone should reallly really I mean really just learn Ruby before they get far into Rails... It does not help having to walk miles backwards just to go get your keys again... -- Posted via http://www.ruby-forum.com/.
Are you going to take your own advice? I don''t see why a person can''t do both at the same time. -Brian On 6/30/06, trip dragon <colo0logo@gmail.com> wrote:> > Brian Chamberlain wrote: > > Yes, it is confusing...but I''ll give it a try. > > > > You''re talking about loops. Since these are part of the Ruby language > > and > > not Rails you''ll find information about them in the ruby-doc.org > > > > Looking at your example I think you might want to try: > > <% @products.each do |product| %> > > <%= h(product.description) %> > > <% end %> > > > > ''product'' in this case can be anything...fish, or potatos, or whatever > > as > > long as it has the method called description you''ll be good to go. > > If you want to find out what kind of object product is (assuming you > > have an > > mixed array of different types of objects) > > <%= h(product.class) %> > > AND if you want to really get crazy you can look at the class of the > > object > > in your array and render different partials for each class > > > > -Brian > > > > Yikes,,,, Everyone should reallly really I mean really just learn Ruby > before they get far into Rails... It does not help having to walk miles > backwards just to go get your keys again... > > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060630/7c8cd362/attachment.html