Hi, I use the following code in a view to show a list of states inside a form but I get not result, I mean I get no errors nor the expected HTML code that should be something like <select><option ... @states = State.find(:all, :order => "name") collection_select(:firm, :state_id, @states, :id, :name) Can anyone please tell me why? -- 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 -~----------~----~----~----~------~----~------~--~---
Are you wrapping the collection_select code in <%= %> tags? Nik Nik wrote:> Hi, I use the following code in a view to show a list of states inside a > form but I get not result, I mean I get no errors nor the expected HTML > code that should be something like <select><option ... > > @states = State.find(:all, :order => "name") > collection_select(:firm, :state_id, @states, :id, :name) > > Can anyone please tell me why? >-- Sincerely, William Pratt http://www.billpratt.net billp-YbheRAKfYF4eIZ0/mPfg9Q@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 William, I''m a PHP developer and I''m testing RoR so I thought <% ... %> was right when writing more than one line of code! I just added "=" after "<%" and it worked. Thanks a lot! These are those little errors that can make you waste a lot of time! Nik William Pratt wrote:> Are you wrapping the collection_select code in <%= %> tags? > > Nik Nik wrote: >> Hi, I use the following code in a view to show a list of states inside a >> form but I get not result, I mean I get no errors nor the expected HTML >> code that should be something like <select><option ... >> >> @states = State.find(:all, :order => "name") >> collection_select(:firm, :state_id, @states, :id, :name) >> >> Can anyone please tell me why? >> > > -- > Sincerely, > > William Pratt > > http://www.billpratt.net > billp-YbheRAKfYF4eIZ0/mPfg9Q@public.gmane.org-- 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 -~----------~----~----~----~------~----~------~--~---
No problem. <% %> should be around code that you do not want the output added to the rendered page (adding a dash at the end like -%> will suppress the newline) and <%= %> goes around code that will generate output to be included in the rendered page. Hope this helps you. Nik Nik wrote:> Hi William, > I''m a PHP developer and I''m testing RoR so I thought <% ... %> was right > when writing more than one line of code! I just added "=" after "<%" and > it worked. > Thanks a lot! These are those little errors that can make you waste a > lot of time! > Nik > > William Pratt wrote: > >> Are you wrapping the collection_select code in <%= %> tags? >> >> Nik Nik wrote: >> >>> Hi, I use the following code in a view to show a list of states inside a >>> form but I get not result, I mean I get no errors nor the expected HTML >>> code that should be something like <select><option ... >>> >>> @states = State.find(:all, :order => "name") >>> collection_select(:firm, :state_id, @states, :id, :name) >>> >>> Can anyone please tell me why? >>> >>> >> -- >> Sincerely, >> >> William Pratt >> >> http://www.billpratt.net >> billp-YbheRAKfYF4eIZ0/mPfg9Q@public.gmane.org >> > >-- Sincerely, William Pratt http://www.billpratt.net billp-YbheRAKfYF4eIZ0/mPfg9Q@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yes, very clear. Thanks again. -- 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 -~----------~----~----~----~------~----~------~--~---