rails/rails — Issue #3787: Active Record Helper form(record_name, options={}) fails (but simple fix)
Author: rshubbard
Created: 2011-11-28 18:21:16+00:00
State: open

This is a duplicate of https://github.com/rails/rails/issues/632 which is still an issue on Rails 2.1, 2.2, and 2.3.

Copied from https://github.com/rails/rails/issues/632:

Imported from Lighthouse. Original ticket at: http://rails.lighthouseapp.com/projects/8994/tickets/3149
Created by jeffp - 2010-11-17 01:58:29 UTC

Location: actionpack-2.3.4/lib/action_view/helpers/active_record_helpers.rb

Line with error
contents = form_tag({:action => action}, :method =>(options[:method] || 'post'), :encrypt => ...

Fix
contents = form_tag(action, :method=>(options[:method] || 'post'), :encrypt => ...

Description
The 'action' variable has already been cast as a URL with url_for a few lines before this. It is not proper to use it as a value for :action in a hash when sending it to form_tag.