# Link\_to passing multiple parameters problem

**URL:** <https://www.ruby-forum.com/t/link-to-passing-multiple-parameters-problem/112782>\
**Category:** Rails\
**Created:** [August 23, 2007, 6:55am UTC](https://www.ruby-forum.com/t/link-to-passing-multiple-parameters-problem/112782 "2007-08-23T06:55:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chilaquil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/fbc32d/32.png) [@chilaquil](https://www.ruby-forum.com/u/chilaquil)\
**Post date:** [August 23, 2007, 6:55am UTC](https://www.ruby-forum.com/t/link-to-passing-multiple-parameters-problem/112782/1 "2007-08-23T06:55:04Z")

</div>

Hi,

I have a problem passing two values through link\_to.

I have the following code in my view  
.  
.  
.  
\<%link\_to “reply”, {:action =\> :reply, :id =\> @topic.id, :reply\_to =\>  
@reply.id}%\>  
.  
.  
.  
In my controller I try to find the @topic and @reply\_to by using the :id  
and :reply\_to values. However, when I commit post the @reply\_to object  
becomes null. If I change the name of the variable :reply\_to in my view  
to :id (and the :id to :topic) it works fine but then the @topic will  
be null. Any idea why? any help will be greatly appreciated.

def reply

@topic = Topic.find\_by\_id(params[:id])  
@reply\_to = Reply.find\_by\_id(params[:reply\_to])  
@reply = Reply.new(params[:reply])  
@reply.topic = @topic  
@reply.reply\_to\_id = @reply\_to.id

if request.post?  
if params[:commit] == “Cancel”  
flash[:notice] = “Cancelled”  
redirect\_to(params[:referer] || :back)  
elsif params[:commit] == “Post”  
if @reply.save  
flash[:notice] = “Successful post”  
redirect\_to (params[:referer] || :back)  
end  
end  
end  
end

Many thanks,  
Andy
