# Trivial syntax error: Unexpected ')'

**URL:** <https://www.ruby-forum.com/t/trivial-syntax-error-unexpected/120385>\
**Category:** Rails\
**Created:** [November 16, 2007, 12:36pm UTC](https://www.ruby-forum.com/t/trivial-syntax-error-unexpected/120385 "2007-11-16T12:36:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mukesh23singh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b38774/32.png) [@mukesh23singh](https://www.ruby-forum.com/u/mukesh23singh)\
**Post date:** [November 16, 2007, 12:36pm UTC](https://www.ruby-forum.com/t/trivial-syntax-error-unexpected/120385/1 "2007-11-16T12:36:29Z")

</div>

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](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:

 Category \<%= @categories.each do |category| %\> \> \<%= category.name %\> \<% end %\> 

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.

---

<div class="post-metadata">

**Author:** ![mukesh23singh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b38774/32.png) [@mukesh23singh](https://www.ruby-forum.com/u/mukesh23singh)\
**Post date:** [November 16, 2007, 12:41pm UTC](https://www.ruby-forum.com/t/trivial-syntax-error-unexpected/120385/2 "2007-11-16T12:41:24Z")

</div>

\<%= @categories.each do |category| %\>

should be  
\<% @categories.each do |category| %\>

---

<div class="post-metadata">

**Author:** ![mukesh23singh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b38774/32.png) [@mukesh23singh](https://www.ruby-forum.com/u/mukesh23singh)\
**Post date:** [November 16, 2007, 12:48pm UTC](https://www.ruby-forum.com/t/trivial-syntax-error-unexpected/120385/3 "2007-11-16T12:48:11Z")

</div>

Good lord! I can be so careless. Thanks a lot, Thorsten M… 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 M. \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![mukesh23singh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b38774/32.png) [@mukesh23singh](https://www.ruby-forum.com/u/mukesh23singh)\
**Post date:** [November 16, 2007, 12:52pm UTC](https://www.ruby-forum.com/t/trivial-syntax-error-unexpected/120385/4 "2007-11-16T12:52:18Z")

</div>

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 M. \<rails-mailing-l…@andreas-
