Ruby on Rails Thursday, July 1, 2010

On 1 July 2010 09:41, Neil Bye <lists@ruby-forum.com> wrote:
> Colin Law wrote:
>> On 30 June 2010 23:45, Neil Bye <lists@ruby-forum.com> wrote:
>>>> @story.id? �You could just display it on the page
>>>
>  You can
>> also look at the html of the page (view page source in browser) to
>> check that the id is there in the href.
>>
>> Add code to show the id on the page and check that it also appears in
>> the href.
>>
>> Colin
>
> This is from show.html.erb
>
> <%= @story.id %>
> <%= link_to "Email this user",
> :controller => "email", :action => "correspond" , :id => "@story_id"

That is passing the string "@story_id" as the id, you want the value,
so just :id => @story_id

>  %>
>
> This is view source
>
> 2
> <a href="/email/correspond/@story_id">Email this user</a>
>
> This is the error that results
>
> Couldn't find Story with ID=@story_id

You should have been able to work it out from this, it is getting the
string @story_id instead of 2

Colin

>
> Where am I going wrong

--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment