Link_to passing multiple parameters problem

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs