This project is archived and is in readonly mode.
Generators spew stack traces when no type is provided for attributes
Reported by Christian Johansen | August 25th, 2010 @ 08:44 PM
script/rails generate MyModel name
If you leave out the type of the attribute (i.e. should be name:string or similar in the above example), Rails spews a stack trace and exits. Would be helpful with a descriptive error message.
Comments and changes to this ticket
-
Rohit Arondekar August 26th, 2010 @ 04:08 AM
- State changed from new to open
- Assigned user set to Rohit Arondekar
- Importance changed from to Low
Confirmed.
~/bugmash/devapp९ script/rails generate model MyModel name /home/rohit/projects/rails/activesupport/lib/active_support/whiny_nil.rb:48:in `method_missing': undefined method `to_sym' for nil:NilClass (NoMethodError) from /home/rohit/projects/rails/railties/lib/rails/generators/generated_attribute.rb:9:in `initialize' from /home/rohit/projects/rails/railties/lib/rails/generators/named_base.rb:92:in `new' from /home/rohit/projects/rails/railties/lib/rails/generators/named_base.rb:92:in `block in parse_attributes!' from /home/rohit/projects/rails/railties/lib/rails/generators/named_base.rb:90:in `map' from /home/rohit/projects/rails/railties/lib/rails/generators/named_base.rb:90:in `parse_attributes!' from /home/rohit/projects/rails/railties/lib/rails/generators/named_base.rb:14:in `initialize' from /home/rohit/.rvm/gems/ruby-1.9.2-p0@3-dev/gems/thor-0.14.0/lib/thor/group.rb:226:in `new' from /home/rohit/.rvm/gems/ruby-1.9.2-p0@3-dev/gems/thor-0.14.0/lib/thor/group.rb:226:in `dispatch' from /home/rohit/.rvm/gems/ruby-1.9.2-p0@3-dev/gems/thor-0.14.0/lib/thor/base.rb:389:in `start' from /home/rohit/projects/rails/railties/lib/rails/generators.rb:163:in `invoke' from /home/rohit/projects/rails/railties/lib/rails/commands/generate.rb:10:in `<top (required)>' from /home/rohit/projects/rails/activesupport/lib/active_support/dependencies.rb:239:in `require' from /home/rohit/projects/rails/activesupport/lib/active_support/dependencies.rb:239:in `block in require' from /home/rohit/projects/rails/activesupport/lib/active_support/dependencies.rb:225:in `block in load_dependency' from /home/rohit/projects/rails/activesupport/lib/active_support/dependencies.rb:591:in `new_constants_in' from /home/rohit/projects/rails/activesupport/lib/active_support/dependencies.rb:225:in `load_dependency' from /home/rohit/projects/rails/activesupport/lib/active_support/dependencies.rb:239:in `require' from /home/rohit/projects/rails/railties/lib/rails/commands.rb:17:in `<top (required)>' from script/rails:6:in `require' from script/rails:6:in `<main>'
Would certainly be nice if there was an error message stating that the field needs a type.
Would you be interested in making a patch? This will be helpful: Contributor Guide
-
Rohit Arondekar September 2nd, 2010 @ 11:01 AM
- Assigned user changed from Rohit Arondekar to José Valim
How about this?
~/bugmash/error_app९ script/rails g model FooBar foo Missing type for attribute 'foo'. Example: 'foo:string' where string is the type. ~/bugmash/error_app९ script/rails g model FooBar title:string count:integer body Missing type for attribute 'body'. Example: 'body:string' where string is the type.
Since LH ate my patch, here is a gist: https://gist.github.com/4b0028201b5fe613baba
-
Repository September 2nd, 2010 @ 12:00 PM
(from [8ffa695cecfbaf63f2ad15adcc06593df8432976]) Failing test for GeneratedAttribute [#5461 state:open]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/8ffa695cecfbaf63f2ad15adcc0659... -
Repository September 2nd, 2010 @ 12:00 PM
- State changed from open to resolved
(from [d2fc5e2f6575b4111f2f87ebca7f021e681d4df9]) Output a friendly message when no type given for GeneratedAttribute [#5461 state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/d2fc5e2f6575b4111f2f87ebca7f02... -
Repository September 2nd, 2010 @ 12:00 PM
(from [13d2a081645db873379668b6f21e449201b6b036]) Add two integration tests for GeneratedAttribute missing type error. [#5461 state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/13d2a081645db873379668b6f21e44... -
Repository September 2nd, 2010 @ 12:01 PM
- State changed from resolved to open
(from [5c067772933602b1783d73df70d89ac259bdc887]) Failing test for GeneratedAttribute [#5461 state:open]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/5c067772933602b1783d73df70d89a... -
Repository September 2nd, 2010 @ 12:01 PM
- State changed from open to resolved
(from [6a60387dce327b038ab16e1950d723e7b02a063d]) Add two integration tests for GeneratedAttribute missing type error. [#5461 state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/6a60387dce327b038ab16e1950d723... -
Repository September 2nd, 2010 @ 12:01 PM
(from [233e0e8ce8a188d98a6bf87fae8caf5b708224b7]) Output a friendly message when no type given for GeneratedAttribute [#5461 state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/233e0e8ce8a188d98a6bf87fae8caf...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 5461 Generators spew stack traces when no type is provided for attributes (from [8ffa695cecfbaf63f2ad15adcc06593df8432976]) Failing...
- 5461 Generators spew stack traces when no type is provided for attributes (from [d2fc5e2f6575b4111f2f87ebca7f021e681d4df9]) Output ...
- 5461 Generators spew stack traces when no type is provided for attributes (from [13d2a081645db873379668b6f21e449201b6b036]) Add two...
- 5461 Generators spew stack traces when no type is provided for attributes (from [5c067772933602b1783d73df70d89ac259bdc887]) Failing...
- 5461 Generators spew stack traces when no type is provided for attributes (from [6a60387dce327b038ab16e1950d723e7b02a063d]) Add two...
- 5461 Generators spew stack traces when no type is provided for attributes (from [233e0e8ce8a188d98a6bf87fae8caf5b708224b7]) Output ...