Breaks rails generate scaffold #7

Closed
jits opened this Issue Feb 18, 2011 · 20 comments

Comments

Projects
None yet
10 participants

jits commented Feb 18, 2011

Hi,

As mentioned here: http://www.ruby-forum.com/topic/701337 ... railroady seems to break the rails generate scaffold command (rails 3.0.4).

Another stack trace...

$ rails generate scaffold Widgets name:string
Plural version of the model detected, using singularized version. Override with --force-plural.
      invoke  active_record
      create    db/migrate/20110218131719_create_widgets.rb
      create    app/models/widget.rb
      invoke    rspec
      create      spec/models/widget_spec.rb
      invoke      factory_girl
      create        test/factories/widgets.rb
       route  resources :widgets
      invoke  scaffold_controller
      create    app/controllers/widgets_controller.rb
(erb):5:in `template': undefined method `all' for ActiveModel:Module (NoMethodError)
    from {ruby 1.9.2}/lib/ruby/1.9.1/erb.rb:753:in `eval'
    from {ruby 1.9.2}/lib/ruby/1.9.1/erb.rb:753:in `result'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/actions/file_manipulation.rb:111:in `block in template'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/actions/create_file.rb:54:in `call'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/actions/create_file.rb:54:in `render'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/actions/create_file.rb:63:in `block (2 levels) in invoke!'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/actions/create_file.rb:63:in `open'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/actions/create_file.rb:63:in `block in invoke!'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:114:in `call'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:114:in `invoke_with_conflict_check'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/actions/create_file.rb:61:in `invoke!'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/actions.rb:95:in `action'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/actions/create_file.rb:26:in `create_file'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/actions/file_manipulation.rb:110:in `template'
    from {ruby 1.9.2 gems}/gems/railties-3.0.4/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb:14:in `create_controller_files'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `block in invoke_all'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `each'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `map'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `invoke_all'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/group.rb:226:in `dispatch'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/invocation.rb:109:in `invoke'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/group.rb:269:in `block in _invoke_for_class_method'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/shell.rb:74:in `with_padding'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/group.rb:258:in `_invoke_for_class_method'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/group.rb:150:in `_invoke_from_option_scaffold_controller'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `block in invoke_all'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `each'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `map'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `invoke_all'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/group.rb:226:in `dispatch'
    from {ruby 1.9.2 gems}/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
    from {ruby 1.9.2 gems}/gems/railties-3.0.4/lib/rails/generators.rb:163:in `invoke'
    from {ruby 1.9.2 gems}/gems/railties-3.0.4/lib/rails/commands/generate.rb:10:in `<top (required)>'
    from {ruby 1.9.2 gems}/gems/activesupport-3.0.4/lib/active_support/dependencies.rb:239:in `require'
    from {ruby 1.9.2 gems}/gems/activesupport-3.0.4/lib/active_support/dependencies.rb:239:in `block in require'
    from {ruby 1.9.2 gems}/gems/activesupport-3.0.4/lib/active_support/dependencies.rb:225:in `block in load_dependency'
    from {ruby 1.9.2 gems}/gems/activesupport-3.0.4/lib/active_support/dependencies.rb:596:in `new_constants_in'
    from {ruby 1.9.2 gems}/gems/activesupport-3.0.4/lib/active_support/dependencies.rb:225:in `load_dependency'
    from {ruby 1.9.2 gems}/gems/activesupport-3.0.4/lib/active_support/dependencies.rb:239:in `require'
    from {ruby 1.9.2 gems}/gems/railties-3.0.4/lib/rails/commands.rb:17:in `<top (required)>'    
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Jits

Owner

preston commented Feb 18, 2011

Hi Jits,

Thank you for the bug report. I'm not sure what exactly the issue is but I'll definitely take a look. If it's indeed railroady causing this issue, I'd say it's a pretty important bug to address. Thanks and please let me know if you have any more clues.

Preston

jits commented Feb 21, 2011

Great, thanks Preston!

I've only had a cursory glance, but let me know if there's anything else I can do to dig deeper into this.

Cheers,
Jits

This happened for me today as well.

Using Rails 3.1 beta, I have no problem without railroady in my gem file, but I get this error as soon as I add it in and try to generate a scaffold.

Owner

preston commented May 22, 2011

Yep.. it's a known issue that just hasn't been debugged yet.

aslam commented Jun 23, 2011

Breaks in Rails 3.0.7 too. ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux].

turadg commented Aug 16, 2011

+1

hagope commented Nov 5, 2011

breaks 3.1.1 thanks to this post for realizing it was railroady :)

@ghost ghost assigned sandipransing Nov 18, 2011

dougc84 commented Dec 12, 2011

+1 - on rails 3.1.3 and ruby 1.9.3 - same error.

Owner

preston commented Dec 15, 2011

@sandipransing Has this been patched yet? AFAIK no one has contributed a fix yet.

Collaborator

sandipransing commented Jan 5, 2012

ruby -v
ruby 1.9.3p0 (2011-11-08 revision 33661) [x86_64-linux]

gem 'rails', '3.1.1'
group :development, :test do
gem "railroady", "~> 1.0.4"
end


rails g scaffold post name:string body:text
invoke active_record
create db/migrate/20120105193508_create_posts.rb
create app/models/post.rb
invoke rspec
create spec/models/post_spec.rb
route resources :posts
invoke inherited_resources_controller
create app/controllers/posts_controller.rb
invoke haml
create app/views/posts
create app/views/posts/index.html.haml
create app/views/posts/edit.html.haml
create app/views/posts/show.html.haml
create app/views/posts/new.html.haml
create app/views/posts/_form.html.haml
invoke rspec
create spec/controllers/posts_controller_spec.rb
create spec/views/posts/edit.html.haml_spec.rb
create spec/views/posts/index.html.haml_spec.rb
create spec/views/posts/new.html.haml_spec.rb
create spec/views/posts/show.html.haml_spec.rb
invoke helper
create spec/helpers/posts_helper_spec.rb
create spec/routing/posts_routing_spec.rb
invoke helper
create app/helpers/posts_helper.rb
invoke rspec
invoke assets
invoke coffee
create app/assets/javascripts/posts.js.coffee
invoke scss
create app/assets/stylesheets/posts.css.scss
invoke scss
identical app/assets/stylesheets/scaffolds.css.scss

Looks like issue has been got resolved. If any one still facing some issue kindly give us more details. thx!

jazzdan commented Jan 5, 2012

This is still an issue for me. Here is my environment:

ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]
rails -v
Rails 3.1.1

invoke active_record create db/migrate/20120105214450_create_images.rb create app/models/image.rb invoke test_unit create test/unit/image_test.rb create test/fixtures/images.yml route resources :images invoke scaffold_controller create app/controllers/images_controller.rb (erb):6:inblock in template': undefined method all' for ActiveModel:Module (NoMethodError) from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/actions/file_manipulation.rb:259:incall'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/actions/file_manipulation.rb:259:in block in capture' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/actions/file_manipulation.rb:264:inwith_output_buffer'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/actions/file_manipulation.rb:259:in capture' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.1/lib/rails/generators/named_base.rb:39:inmodule_namespacing'
from (erb):1:in template' from /Users/dan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/erb.rb:838:ineval'
from /Users/dan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/erb.rb:838:in result' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/actions/file_manipulation.rb:111:inblock in template'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/actions/create_file.rb:54:in call' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/actions/create_file.rb:54:inrender'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/actions/create_file.rb:63:in block (2 levels) in invoke!' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/actions/create_file.rb:63:inopen'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/actions/create_file.rb:63:in block in invoke!' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:114:incall'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:114:in invoke_with_conflict_check' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/actions/create_file.rb:61:ininvoke!'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/actions.rb:95:in action' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/actions/create_file.rb:26:increate_file'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/actions/file_manipulation.rb:110:in template' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.1/lib/rails/generators/named_base.rb:27:inblock in template'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.1/lib/rails/generators/named_base.rb:56:in inside_template' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.1/lib/rails/generators/named_base.rb:26:intemplate'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.1/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb:14:in create_controller_files' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/task.rb:22:inrun'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/invocation.rb:118:in invoke_task' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/invocation.rb:124:inblock in invoke_all'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/invocation.rb:124:in each' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/invocation.rb:124:inmap'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/invocation.rb:124:in invoke_all' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/group.rb:226:indispatch'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/invocation.rb:109:in invoke' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/group.rb:269:inblock in _invoke_for_class_method'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/shell.rb:74:in with_padding' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/group.rb:258:in_invoke_for_class_method'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/group.rb:150:in _invoke_from_option_scaffold_controller' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/task.rb:22:inrun'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/invocation.rb:118:in invoke_task' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/invocation.rb:124:inblock in invoke_all'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/invocation.rb:124:in each' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/invocation.rb:124:inmap'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/invocation.rb:124:in invoke_all' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/group.rb:226:indispatch'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/thor-0.14.6/lib/thor/base.rb:389:in start' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.1/lib/rails/generators.rb:168:ininvoke'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.1/lib/rails/commands/generate.rb:12:in <top (required)>' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:inrequire'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in block in require' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:inblock in load_dependency'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:640:in new_constants_in' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:inload_dependency'
from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in require' from /Users/dan/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.1/lib/rails/commands.rb:28:in<top (required)>'
from script/rails:6:in require' from script/rails:6:in

'`

davidw commented Feb 2, 2012

I have tracked it down to this, in app_diagram.rb:

  def constantize
     names = self.split('::')
     names.shift if names.empty? || names.first.empty?

     constant = Object
     names.each do |name|
       constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
     end
     constant
   end

Via the simple means of commenting and uncommenting stuff until it breaks.

Collaborator

sandipransing commented Feb 2, 2012

@davidw can you pl. fork repo. and send pull request for this issue.

davidw commented Feb 2, 2012

I would if I knew an actual fix, sorry:-( I just traced it down to that code as something responsible for the crash.

Collaborator

sandipransing commented Feb 2, 2012

Ah..its okk ..very much thanks for trace! ...actually issue is not getting reproduced at my end otherwise i would have fixed it.

davidw commented Feb 2, 2012

Rails 3.2 and Ruby 1.9.2 on Ubuntu 11.10.

Using rvm, create a new rails instance, add railroady to your Gemfile, and then try: rails generate scaffold Foobar. Bang!

Collaborator

sandipransing commented Feb 2, 2012

@preston Is there any particular reason in overriding camelize & constantize methods of string class ?

Collaborator

sandipransing commented Feb 2, 2012

@davidw can you install railroady from source and let me know if you face any issues ?

gem 'railroady', :git => 'git://github.com/preston/railroady.git'

Collaborator

sandipransing commented Feb 3, 2012

string override of constantize method was causing issue. released # v1.0.6

davidw commented Feb 3, 2012

Yeah, works here. Thanks guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment