Wanderwelten
2010-Apr-25 10:25 UTC
link_to :remote with parameters not working in Rails 3?
Hey community, since some day i dive into Rails and started with the basics for developing applications. Yesterday i spend a lot of time for how to create a remote''able link_to with parameters. What orginally should worked is this code-sample: <%= link_to "Click here", index_path, :remote => true, :picture => "12" %> which creates the following html-code: <a href="/index" data- remote="true" picture="21">Click here</a> My controller receive''s the Ajax Get-Request but without any parameter (checked my logfiles too). After some testing i found a solution for submitting paramters on a remote call: <%= link_to "Click here", { :controller => :index, :action => :index, :picture => 21 }, :remote => true %> <a data-remote="true" href="/times?picture=21">Click here</a> So, why does the first example not working in Rails 3 anymore? And how should i do it correctly in Rails 3? Greets, Gerrit -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Wanderwelten
2010-May-10 11:58 UTC
Re: link_to :remote with parameters not working in Rails 3?
I found now a solution...the params must be set into the target- parameter <%= link_to image_tag("/images/sample.gif"), product_path(:customer_id => customer.id), :remote => true %> Wanderwelten wrote:> Hey community, > > since some day i dive into Rails and started with the basics for > developing applications. Yesterday i spend a lot of time for how to > create a remote''able link_to with parameters. What orginally should > worked is this code-sample: > <%= link_to "Click here", index_path, :remote => true, :picture => > "12" %> which creates the following html-code: <a href="/index" data- > remote="true" picture="21">Click here</a> > My controller receive''s the Ajax Get-Request but without any parameter > (checked my logfiles too). > > After some testing i found a solution for submitting paramters on a > remote call: > <%= link_to "Click here", { :controller => :index, :action > => :index, :picture => 21 }, :remote => true %> > <a data-remote="true" href="/times?picture=21">Click here</a> > > So, why does the first example not working in Rails 3 anymore? And how > should i do it correctly in Rails 3? > > Greets, Gerrit > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.