Unable to make observe_field work

I can’t make it work.

<%= text_field_tag :friend %>

<%= observe_field :friend, :url => friendships_url, :on => :click %>

<%= javascript_include_tag :defaults %>

Raises the error:Can’t find variable Form.

The generated html is:

The:

<%= javascript_include_tag :defaults %>

Should appear BEFORE the:

<%= observe_field :friend, :url => friendships_url, :on => :click %>

It’s usually placed at your page’s section.

Maurício Linhares
http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr

On Sun, Jun 14, 2009 at 6:18 PM, Fernando

Thanks Mauricio! So stupid of me!

Do I need to set a respond_to block in the update action of the
controller for rjs? I don’t understand what’s missing, and the rails api
is rather thin on the subject.

Just to save people 1hr of head banging:

This DOES NOT WORK: (data is submitted to ApplicationController/index!!!
<%= observe_field :friendship_accessibility, :url =>
friendship_url(friendship),
:on => :click, :with => :accessibility %>

This works: (all options are compulsory)
<%= observe_field :friendship_accessibility,
:url => {:controller => ‘friendships’, :action => ‘update’, :id =>
friendship},
:on => :click, :with => :accessibility, :method => :update %>

Is that a bug? Why can’t the observe_field and Rails routing mechanism
recognize the restful route?

You don’t have an :update specified on the parameters for
observe_field. Assuming you don’t want to render anything, do a
render :nothing=>true in the controller.

On Jun 15, 2:53 am, Fernando P. [email protected]

Mukund wrote:

You don’t have an :update specified on the parameters for
observe_field. Assuming you don’t want to render anything, do a
render :nothing=>true in the controller.
The problem is that it’s ApplicationController#index that processes the
submitted data. I don’t understand why. The url is correctly formed.