Form_remote_tag not working

I’m working through Agile Web Dev. On page 130, you change an add to
cart button that posts to a new page to a button that does an Ajax
post. The code changes from button_to to form_remote_tag with
arguments.

But when I use that tag nothing appears on the page. (And there’s
nothing in the source. Rails just ignores the tag entirely.)

<% form_remote_tag :url => { :action => :add_to_cart, :id => product 

} do %>
<%= submit_tag “Add to Cart” %>
<% end %>

I’ve swapped my code for the code downloaded from the book, but still
nothing.

First, am I missing something? Second, how does one trouble-shoot
these kinds of problems? View source gives me nada and rails tells me
nothing. Where do I look to troubleshoot?

Thanks,

Austin G.
Thinking & Making: IA, UX, and IxD
http://thinkingandmaking.com
[email protected]

First, am I missing something?

Yes. Your ‘<% form_remote_tag’ should be ‘<%= form_remote_tag’.

Second, how does one trouble-shoot
these kinds of problems? View source gives me nada and rails tells me
nothing. Where do I look to troubleshoot?

Content not even appearing may well be something you’re going to have
to debug for yourself. If you’re anything like me, a few times of
leaving off the = sign as you have done here, and you’ll soon learn
how to diagnose this particular problem! :slight_smile:

If you’re doing anything with Ajax and RJS, I can’t recommend the
FireBug extension for Firefox enough. It’s a real godsend.

Scott

On Nov 7, 2006, at 11:37 AM, Austin G. wrote:

  <%= submit_tag "Add to Cart" %>
<% end %>

I’ve swapped my code for the code downloaded from the book, but
still nothing.

First, am I missing something? Second, how does one trouble-shoot
these kinds of problems? View source gives me nada and rails tells me
nothing. Where do I look to troubleshoot?

You need Edge Rails to use the new-style form_tag and form_remote_tag
helpers.

If you’d rather not install via Subversion, I’ve prepared a zip file
of today’s Edge rails. Download

http://media.pragprog.com/titles/rails2/code.rails.zip

into your application’s vendor/ directory, and then unzip it. Then go
back to your applications main directory and type

rake rails:update

If you restart your application, all the new stuff should work.

DON’T USE THIS IN PRODUCTION. NO WARRANTIES. ETC.

Dave

I updated to the most recent version of rails and that fixed it.
(Though, I thought I was already on a recent enough edge.)

And I guess that answers a troubl-shooting question: verify the
feature you’re using against the rails version you’re using.

Thanks,

Austin

On 11/7/06, Dave T. [email protected] wrote:

nothing in the source. Rails just ignores the tag entirely.)
these kinds of problems? View source gives me nada and rails tells me
into your application’s vendor/ directory, and then unzip it. Then go
Dave


Austin G.
Thinking & Making: IA, UX, and IxD
http://thinkingandmaking.com
[email protected]