[Rails] Re: Restfull routes, link_to, and additional paramters
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.
http://www.w3.org/2001/tag/doc/whenToUseGet.html
Also you should think about "Progressive Enhancement" and what happens
when people do not have have Javascript available. Using :method
requires Javascript to create a form on the fly in memory. It is just
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
with to_s.
<%= link_to("create", foos_path(@foo, :bar_id => @bar.id.to_s), :method => :post) %>
Are you including default Javascript libraries? IIRC that is needed.
Not sure though.
<%= javascript_include_tag :defaults %>
Good luck!
Bob
--
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home