I have a controller called "Notes", and its associated model is Note, with a text field called "note" (I know).
I have a very simple form in the new.html.erb view:
<% form_for(@note) do |f| %>
<p><%= f.error_messages %> </p>
<h2 class="productList"><label for="">Note: </label>
<%= f.text_area :note, :cols => "50", :rows => "10" %></h2>
<br />
<p><%= f.submit "Create" %></p>
<% end %>
However, upon clicking the "Submit" button, the action being called is from a completely different controller:
Processing OtherController#add_note (for 127.0.0.1 at 2012-07-30 09:04:42) [POST]
Please note that this action is not even defined in routes.rb, though the controller is set up as a resource.
My "notes" line in routes.rb looks like this:
map.resources :notes, :collection => { :note_list => :get, :get_json_list => :get }, :member => { :applications => :get, :replace => :get }
And "rake routes" yields these lines for the controller:
get_json_list_notes GET /notes/get_json_list(.:format) {:controller=>"notes", :action=>"get_json_list"}
note_list_notes GET /notes/note_list(.:format) {:controller=>"notes", :action=>"note_list"}
notes GET /notes(.:format) {:controller=>"notes", :action=>"index"}
POST /notes(.:format) {:controller=>"notes", :action=>"create"}
new_note GET /notes/new(.:format) {:controller=>"notes", :action=>"new"}
edit_note GET /notes/:id/edit(.:format) {:controller=>"notes", :action=>"edit"}
replace_note GET /notes/:id/replace(.:format) {:controller=>"notes", :action=>"replace"}
applications_note GET /notes/:id/applications(.:format) {:controller=>"notes", :action=>"applications"}
note GET /notes/:id(.:format) {:controller=>"notes", :action=>"show"}
PUT /notes/:id(.:format) {:controller=>"notes", :action=>"update"}
DELETE /notes/:id(.:format) {:controller=>"notes", :action=>"destroy"}
I don't have anything bound to the form or controls in my Javascript either. What would make it call the wrong controller and action?
UPDATE - Here is the output of the form_for tag:
<form id="new_note" class="new_note" method="post" action="/notes">
<p> </p>
<h2 class="productList">
<label for="">Note: </label>
<textarea id="note_text" rows="10" name="note_text" cols="50"></textarea>
</h2>
<br>
<p>
<input id="note_submit" type="submit" value="Create" name="commit">
</p>
</form>
UPDATE 2 - Form is being passed "Note.new"