Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #62 (closed enhancement: wontfix)

Opened 5 years ago

Last modified 3 years ago

‘open’ and 'notify' not valid column names

Reported by: anonymous Assigned to: David
Priority: high Milestone: 0.9.5
Component: ActionWebService Version: 0.9
Severity: minor Keywords:
Cc:

Description

Create a table with a column named ‘open’ (sqlite in this case) Use Scaffolding (with suffix) do ‘list_Yourtable’ click on ‘New’

Change History

10/19/04 22:46:37 changed by david

Please describe the full problem instead of only the steps to replicate.

10/27/04 21:00:48 changed by sean@seansantry.com

  • version changed from 0.7 to 0.8.
  • milestone changed from 0.8 to 0.9.

Though I wasn't the original submitter, I've encountered the same problem with Rails 0.8.0 ActionPack 0.9.0 and a MySQL database. Here's some more detail:

I have a bugs table with a column named "open":

mysql> describe bugs; +-------------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------------+---------------------+------+-----+---------+-------+ | id | int(11) | | | 0 | | | open | tinyint(3) unsigned | YES | | 0 | | | date_opened | datetime | YES | | NULL | | | date_resolved | datetime | YES | | NULL | | | date_closed | datetime | YES | | NULL | |

<snip>

I created a basic controller using scaffold as such:

require 'abstract_application' require 'bug_helper' require 'bug'

class BugController < AbstractApplicationController

include BugHelper

scaffold :bug

end

If I open the URL for the list action (e.g., http://sparkbugs/bug/list), then select the "New bug" link automatically generated by the scaffolding, I get the following trace in the logs:

ActionView::TemplateError (wrong number of arguments (0 for 1)) on line #3 of /usr/lib/ruby/gems/1.8/gems/actionpack-0.9.0/lib/action_controller/templates/scaffolds/new.rhtml: 1: <h1>New <%= @scaffold_singular_name %></h1> 2: 3: <%= form(@scaffold_singular_name, :action => "create" + @scaffold_suffix) %> 4: 5: <%= link_to "Back", :action => "list#{@scaffold_suffix}" %>

/gems/actionpack-0.9.0/lib/action_view/helpers/form_helper.rb:158:in `initialize' /gems/actionpack-0.9.0/lib/action_view/helpers/form_helper.rb:158:in `open' /gems/actionpack-0.9.0/lib/action_view/helpers/form_helper.rb:158:in `send' /gems/actionpack-0.9.0/lib/action_view/helpers/form_helper.rb:158:in `value' /gems/actionpack-0.9.0/lib/action_view/helpers/form_helper.rb:114:in `to_input_field_tag' /gems/actionpack-0.9.0/lib/action_view/helpers/active_record_helper.rb:110:in `to_tag' /gems/actionpack-0.9.0/lib/action_view/helpers/active_record_helper.rb:21:in `input' /gems/actionpack-0.9.0/lib/action_view/helpers/active_record_helper.rb:97:in `default_input_block' /gems/actionpack-0.9.0/lib/action_view/helpers/active_record_helper.rb:97:in `call' /gems/actionpack-0.9.0/lib/action_view/helpers/active_record_helper.rb:93:in `all_input_tags' /gems/actionpack-0.9.0/lib/action_view/helpers/active_record_helper.rb:93:in `collect' /gems/actionpack-0.9.0/lib/action_view/helpers/active_record_helper.rb:93:in `all_input_tags' /gems/actionpack-0.9.0/lib/action_view/helpers/active_record_helper.rb:58:in `form' (erb):3:in `render_template' /gems/actionpack-0.9.0/lib/action_view/base.rb:191:in `render_template' /gems/actionpack-0.9.0/lib/action_view/base.rb:166:in `render_file' /gems/actionpack-0.9.0/lib/action_controller/scaffolding.rb:159:in `render_scaffold' /gems/actionpack-0.9.0/lib/action_controller/scaffolding.rb:119:in `new' /gems/actionpack-0.9.0/lib/action_controller/base.rb:563:in `send' /gems/actionpack-0.9.0/lib/action_controller/base.rb:563:in `perform_action_without_filters' /gems/actionpack-0.9.0/lib/action_controller/filters.rb:236:in `perform_action_without_benchmark' /gems/actionpack-0.9.0/lib/action_controller/benchmarking.rb:30:in `perform_action_without_rescue' /gems/actionpack-0.9.0/lib/action_controller/benchmarking.rb:30:in `measure' /gems/actionpack-0.9.0/lib/action_controller/benchmarking.rb:30:in `perform_action_without_rescue' /gems/actionpack-0.9.0/lib/action_controller/rescue.rb:68:in `perform_action' /gems/actionpack-0.9.0/lib/action_controller/base.rb:254:in `process' /gems/actionpack-0.9.0/lib/action_controller/base.rb:235:in `process' /gems/rails-0.8.0/lib/dispatcher.rb:35:in `dispatch' /Users/santry/Development/sparkbugs/public/dispatch.cgi:10

Rendering /usr/lib/ruby/gems/1.8/gems/actionpack-0.9.0/lib/action_controller/templates/rescues/layout.rhtml (500 Internal Error)

Renaming the column from "open" to "is_open" fixes the problem.

10/27/04 21:21:51 changed by sean@seansantry.com

  • summary changed from ‘open’ not a valid column name to ‘open’ and 'notify' not valid column names.

The same issue occurs with a column named "notify". Here's the stack trace:

<pre> ActionView::TemplateError (wrong number of arguments(0 for 1)) on line #3 of /usr/lib/ruby/gems/1.8/gems/actionpack-0.9.0/lib/action_controller/templates/scaffolds/new.rhtml: 1: <h1>New <%= @scaffold_singular_name %></h1> 2: 3: <%= form(@scaffold_singular_name, :action => "create" + @scaffold_suffix) %> 4: 5: <%= link_to "Back", :action => "list#{@scaffold_suffix}" %>

/gems/actionpack-0.9.0/lib/action_view/helpers/form_helper.rb:158:in `notify' /gems/actionpack-0.9.0/lib/action_view/helpers/form_helper.rb:158:in `send' /gems/actionpack-0.9.0/lib/action_view/helpers/form_helper.rb:158:in `value' /gems/actionpack-0.9.0/lib/action_view/helpers/form_helper.rb:114:in `to_input_field_tag' /gems/actionpack-0.9.0/lib/action_view/helpers/active_record_helper.rb:110:in `to_tag' /gems/actionpack-0.9.0/lib/action_view/helpers/active_record_helper.rb:21:in `input' /gems/actionpack-0.9.0/lib/action_view/helpers/active_record_helper.rb:97:in `default_input_block' /gems/actionpack-0.9.0/lib/action_view/helpers/active_record_helper.rb:97:in `call' /gems/actionpack-0.9.0/lib/action_view/helpers/active_record_helper.rb:93:in `all_input_tags' /gems/actionpack-0.9.0/lib/action_view/helpers/active_record_helper.rb:93:in `collect' /gems/actionpack-0.9.0/lib/action_view/helpers/active_record_helper.rb:93:in `all_input_tags' /gems/actionpack-0.9.0/lib/action_view/helpers/active_record_helper.rb:58:in `form' (erb):3:in `render_template' /gems/actionpack-0.9.0/lib/action_view/base.rb:191:in `render_template' /gems/actionpack-0.9.0/lib/action_view/base.rb:166:in `render_file' /gems/actionpack-0.9.0/lib/action_controller/scaffolding.rb:159:in `render_scaffold' /gems/actionpack-0.9.0/lib/action_controller/scaffolding.rb:119:in `new' /gems/actionpack-0.9.0/lib/action_controller/base.rb:563:in `send' /gems/actionpack-0.9.0/lib/action_controller/base.rb:563:in `perform_action_without_filters' /gems/actionpack-0.9.0/lib/action_controller/filters.rb:236:in `perform_action_without_benchmark' /gems/actionpack-0.9.0/lib/action_controller/benchmarking.rb:30:in `perform_action_without_rescue' /gems/actionpack-0.9.0/lib/action_controller/benchmarking.rb:30:in `measure' /gems/actionpack-0.9.0/lib/action_controller/benchmarking.rb:30:in `perform_action_without_rescue' /gems/actionpack-0.9.0/lib/action_controller/rescue.rb:68:in `perform_action' /gems/actionpack-0.9.0/lib/action_controller/base.rb:254:in `process' /gems/actionpack-0.9.0/lib/action_controller/base.rb:235:in `process' /gems/rails-0.8.0/lib/dispatcher.rb:35:in `dispatch' /Users/santry/Development/sparkbugs/public/dispatch.cgi:10

Rendering /usr/lib/ruby/gems/1.8/gems/actionpack-0.9.0/lib/action_controller/templates/rescues/layout.rhtml (500 Internal Error) </pre>

02/28/05 09:41:22 changed by nzkoz

  • status changed from new to closed.
  • resolution set to wontfix.

Both open and notify are the names for private methods, overriding them means they won't behave correctly when called by rails itself.

I've raised two enhancement requests to replace this defect.

#751 will get these 'reserved words' documented #752 will give you a much nicer error message

If you would like to follow their development please feel free to add yourself to their CC fields.

07/03/06 07:39:48 changed by anonymous

  • severity changed from normal to minor.
  • component changed from ActionPack to ActionWebService.
  • summary changed from ‘open’ and 'notify' not valid column names to ‘open’ and 'notify' not valid column names.
  • priority changed from normal to highest.
  • version changed from 0.8 to 0.9.
  • milestone changed from 0.9 to 0.9.5.
  • type changed from defect to enhancement.