# Syntax problem or something else?

**URL:** <https://www.ruby-forum.com/t/syntax-problem-or-something-else/146931>\
**Category:** Rails\
**Created:** [August 26, 2008, 10:06pm UTC](https://www.ruby-forum.com/t/syntax-problem-or-something-else/146931 "2008-08-26T22:06:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![drsharp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@drsharp](https://www.ruby-forum.com/u/drsharp)\
**Post date:** [August 26, 2008, 10:06pm UTC](https://www.ruby-forum.com/t/syntax-problem-or-something-else/146931/1 "2008-08-26T22:06:50Z")

</div>

Hi, I’m pretty sure this is a simple problem but I can’t seem to work it  
out.  
I have a series of news stories and I would like the body of the story  
to be displayed (using a visual\_effect toggle) when the user clicks on  
the title.

The toggle works ok, but it does not matter which title I click on, only  
the first story is ever displayed.

Can anyone see what is the problem?  
Thanks

## Latest News
\<% for newsitem in @newsitems %\> 

## \<%= link\_to newsitem.title, "#", :onclick =\> visual\_effect(:toggle\_appear, ('newsitem.id'), :duration =\> 0.5) %\>

###### \<%= newsitem.created\_at.strftime('%a %d %b %Y, %I:%M%p') %\> by \<%= newsitem.user.login %\>

\<%= newsitem.body %\>

\<% end %\>

---

<div class="post-metadata">

**Author:** ![drsharp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@drsharp](https://www.ruby-forum.com/u/drsharp)\
**Post date:** [August 26, 2008, 10:44pm UTC](https://www.ruby-forum.com/t/syntax-problem-or-something-else/146931/2 "2008-08-26T22:44:11Z")

</div>

Try replacing  
visual\_effect(:toggle\_appear, (‘newsitem.id’), :duration =\> 0.5) with  
visual\_effect(:toggle\_appear, “#{newsitem.id}”, :duration =\> 0.5)

and

 with

The way you have it is the literal string ‘newsitem.id’.  
“#{newsitem.id}” and \<%= newsitem.id %\> should resolve to what you  
want, the id of the item.

On Aug 26, 2:06 pm, Dan S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![drsharp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@drsharp](https://www.ruby-forum.com/u/drsharp)\
**Post date:** [August 26, 2008, 10:48pm UTC](https://www.ruby-forum.com/t/syntax-problem-or-something-else/146931/3 "2008-08-26T22:48:52Z")

</div>

On Aug 26, 9:06 pm, Dan S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi, I’m pretty sure this is a simple problem but I can’t seem to work it  
> out.  
> I have a series of news stories and I would like the body of the story  
> to be displayed (using a visual\_effect toggle) when the user clicks on  
> the title.
> 
> The toggle works ok, but it does not matter which title I click on, only  
> the first story is ever displayed.

Your problem (which you should be able to see if you looked at the  
html) is that all of your divs have as id the string newsitem.id.  
When you write (‘newsitem.id’) (not sure what you were trying to  
accomplish with the parentheses no interpolation is taking place,  
that’s just a string literal.  
if you want interpolation then you need to use double quotes and #{}  
to indicate what should be interpolated, eg "my name is #{ name } "

Fred
