I am a Rails newbie but have programmed other languages/frameworks earlier. There''s a trivial syntax error I can''t for the life of me figure out. I am following the well-known Ruby On InstantRails tutorial from here: http://instantrails.rubyforge.org/tutorial/index.html I am overriding the default ''edit'' method on the recipe controller. I get the error in the edit.rhtml while creating the drop down for displaying categories. The relevant snippet is produced below: <tr> <td>Category</td> <td> <select id="cboCategory" name="recipe[category_id]"> <%= @categories.each do |category| %> <option value="category.id" <%= ''selected'' if @recipe.category_id == category.id %> > <%= category.name %> </option> <% end %> </select> </td> </tr> I don''t see anything wrong with that. However, I get an error as follows: compile error ./script/../config/../app/views/recipe/edit.rhtml:37: syntax error, unexpected '')'' _erbout.concat "\t\t\t\t\t\t"; _erbout.concat(( @categories.each do | category| ).to_s); _erbout.concat "\n" ^ ./script/../config/../app/views/recipe/edit.rhtml:87: syntax error, unexpected kEND, expecting '')'' I can gather it is complaining about some misplaced paranthesis and ''end'' statement. However, there is no other enumeration/anonymous code block in the code other than the one shown above. Help appreciated. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
<%= @categories.each do |category| %> should be <% @categories.each do |category| %> -- 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 -~----------~----~----~----~------~----~------~--~---
Good lord! I can be so careless. Thanks a lot, Thorsten Muller. This is the second time I made this mistake. I''ll be more careful for myself in the future. Mukesh On Nov 16, 11:41 am, Thorsten Muller <rails-mailing-l...@andreas- s.net> wrote:> <%= @categories.each do |category| %> > > should be > <% @categories.each do |category| %> > -- > 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 -~----------~----~----~----~------~----~------~--~---
Just one other thing. The ''textarea'' I have for displaying instructions inserts many leading and trailing spaces around the actual values. I checked and the database records also have the leading and trailing spaces. However, when I choose to edit a record and trim the trailing and leading spaces around the instructions and issue an update, the spaces are not trimmed. The next time I edit the record, they still appear. Can you help me with this? On Nov 16, 11:41 am, Thorsten Muller <rails-mailing-l...@andreas- s.net> wrote:> <%= @categories.each do |category| %> > > should be > <% @categories.each do |category| %> > -- > 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 -~----------~----~----~----~------~----~------~--~---