# You've got your observe\_form in my peanut butter

**URL:** <https://www.ruby-forum.com/t/youve-got-your-observe-form-in-my-peanut-butter/133096>\
**Category:** Rails\
**Created:** [March 27, 2008, 5:52pm UTC](https://www.ruby-forum.com/t/youve-got-your-observe-form-in-my-peanut-butter/133096 "2008-03-27T17:52:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Russ\_McBride](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f6c823/32.png) [@Russ\_McBride](https://www.ruby-forum.com/u/Russ_McBride)\
**Post date:** [March 27, 2008, 5:52pm UTC](https://www.ruby-forum.com/t/youve-got-your-observe-form-in-my-peanut-butter/133096/1 "2008-03-27T17:52:06Z")

</div>

I’ve got an observe\_form method that calls a remote action (when any  
of the form fields are modified) and then simply displays the result  
in a div tag. Generic. I can’t for the life of my figure out why my  
observe\_form, when triggered, is NOT calling its specified action but  
instead triggers the submit action on the form itself. wtf?!? The  
Ajax action never gets called. Instead the form gets submitted and  
the update action called.

## There’s some kind of weird cross-talk going on between the two. I’ll include the entire view code since it’s pretty simple:

\<% form\_for(:report, :url =\> {:controller =\> ‘reports’, :action =\>  
‘update’},  
:html =\> {:method =\> “put”, :id=\>“report-form”}) do  
|form|  
%\>  
\<%= text\_field ‘report’, ‘name’, :size =\> 50 %\>

```
   <div id="df-result"> </div>

   <%= submit_tag 'Update' %>

```

\<% end %\>

## \<%= observe\_form “report-form”, :url =\> { :action =\> :calculate\_df}, :frequency =\> 1, :update =\> “df-result”, :complete =\> “Element.show(‘df-result’)” %\>

Check out the request parameters when a field is modified:  
{“commit”=\>“Update”,  
“\_method”=\>“put”,  
“authenticity\_token”=\>“012fb6561f2e8a04cc5f391c34c9018467b12a7f”,  
“id”=\>“calculate\_df”,  
“report”=\>{“name”=\>“Blahdisd”}}  
What the heck?? Check out the id. When a field is modified, instead  
of calculate\_df getting called, the update action gets triggered and  
the id of the form object gets set to the name of the ajax action,  
calculate\_df !!

The create form works just fine and calls the Ajax method as it should  
and posts properly when submitted, i.e., everything works fine here:

```
 <% form_for(:report, @report, :url => {:action => "create"},
                        :html => {:method => :post, :id=>"report-

```

form"}) do |form|%\>

I’m using rails 2.0.2 and reports are RESTful.

I found this bug which may or may not be the same one that’s biting me:  
[http://dev.rubyonrails.org/ticket/6662](http://dev.rubyonrails.org/ticket/6662)

Anyone encounter this? Am I missing something?

–russ
