Jonathan Steel wrote:
I am trying to do a link_to with multiple to create an object.
Everything works until ad the second parameter in. As soon as I add the
second parameter, it forgets to add any information about the first one.
What do you mean, "it forgets to add any information about the first
one"? I don't understand what you are trying to say there.
link_to "create", foos_path(@foo, :bar_id => @bar.id), :method => :post
What am I doing incorrect?
You are aware that links should be GET requests and not POST requests,
right? GETs should be safe.
Also you should think about "Progressive Enhancement" and what happens
a normal GET otherwise.
But as to your problem, I am not sure. It works for me. I just
jigged up a test case of your example and I was able to use that same
syntax just fine.
I suggest enclosing the link_to with parenthesis. That can sometimes
enable the error to be more visible with a different ruby message.
<%= link_to("create", foos_path(@foo, :bar_id => @bar.id), :method => :post) %>
Not sure but a shot in the dark. Make sure the parameter is a string
<%= link_to("create", foos_path(@foo, :bar_id => @bar.id.to_s), :method => :post) %>
Not sure though.