Hi everyone Can you please tell me where I can find a good tutorial on loops. By loop I mean something that is related with objects created from a model. I think is called an array loop. And something that combines from 2 tables as well as setting condition which reads only some of the values of the table. For example on a shoping cart may have something which is paid and some which are pending. Thanx -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dom Tek wrote:> Hi everyone > > Can you please tell me where I can find a good tutorial on loops. By > loop I mean something that is related with objects created from a model. > I think is called an array loop. And something that combines from 2 > tables as well as setting condition which reads only some of the values > of the table. For example on a shoping cart may have something which is > paid and some which are pending. > > ThanxLike loop through all the objects that the database brings back? Well if it is this, say you have a controller action that looks like this: def cart @product_orders = Order.find(:all, :conditions => ''user_id = 4'') @pending = Order.find(:all, :conditions => ''user_id = 4 and pending = 1'') end Now in you view you would do something like: <% foreach order in @product_orders %> <!-- then you just call each of the attributes of the order --> Order #: <%= order.id %> <% end %> In this case I used a foreach loop. Alternatively you could do <% @product_orders.each do |order| %> Order #:<%= order.id %> <% end %> I hope this helps. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Scott Yes, that was a very useful example, thank you. Any more or pointers were i can experiment ? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You should definitely take some book in hands. Pick any Rails related or start from the http://www.rubyonrails.org/docs, and try to pass all tutorials. All things will be mush clear. On Aug 4, 6:59 pm, Dom Tek <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi everyone > > Can you please tell me where I can find a good tutorial on loops. By > loop I mean something that is related with objects created from a model. > I think is called an array loop. And something that combines from 2 > tables as well as setting condition which reads only some of the values > of the table. For example on a shoping cart may have something which is > paid and some which are pending. > > Thanx > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dom Tek wrote:> Hi Scott > > Yes, that was a very useful example, thank you. Any more or pointers > were i can experiment ?Definitely pick up a ruby book, or find tutorials online to understand the language (if you already know an OOP language it should look familar). Then pick up a rails book, Agile Web Development w/ Rails by Dave Thomas is really good, and there are other ones out there too, which probably teach the same stuff, it''s just this one is really in depth. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---