Rails 3 link_to :remote

Matt Royer
Mon, 14 Jun 2010 20:44:21 -0000

I recently moved to Rails 3 and am still getting used to some of its new
ways of working.

I have the following code:

----

<%= link_to "#{order.name}", :url => {:controller =>
''orders'', :action
=> ''show'', :id => order.id }, :update =>
"order_div", :method => ''get'',
:remote => true %>

----

I know I''m probably just missing something simple, but I''m not
sure what
it is. I have my javascript included in the application.html.erb file.

This code (excluding the :remote => true) works under Rails 2.3.8 when
using link_to remote. I don''t know what the new arguments require. And
after searching around for exactly what I want this to do, I couldn''t
find anything.

All I want it to do is show the order information in a DIV I named:
order_div

So instead of the ''show'' action moving me to the
/orders/show/etc... I
want it to display the info that show normally would in the same page. I
have a list of orders to click on. Want this to happen without a full
page refresh.

Can anyone help me with the new way Rails handles this sort of thing?

Thanks,

--Matt Royer