Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix NoMethodError that occurs when generating scaffold inside full mode engine #20724

Merged
merged 1 commit into from
Jun 29, 2015
Merged

fix NoMethodError that occurs when generating scaffold inside full mode engine #20724

merged 1 commit into from
Jun 29, 2015

Conversation

y-yagi
Copy link
Member

@y-yagi y-yagi commented Jun 28, 2015

Currently, it is an error to generate the scaffold inside full mode engine.

$ ./bin/rails -v  
Rails 4.2.3 

$ bin/rails g scaffold User name:string
      invoke  active_record
      create    db/migrate/20150628034727_create_users.rb
      create    app/models/user.rb
      invoke    test_unit
      create      test/models/user_test.rb
      create      test/fixtures/users.yml
      invoke  resource_route
       route    resources :users
      invoke  scaffold_controller
      create    app/controllers/users_controller.rb
      invoke    erb
      create      app/views/users
      create      app/views/users/index.html.erb
      create      app/views/users/edit.html.erb
      create      app/views/users/show.html.erb
      create      app/views/users/new.html.erb
      create      app/views/users/_form.html.erb
      invoke    test_unit
      create      test/controllers/users_controller_test.rb
/home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.3/lib/rails/generators/named_base.rb:98:in `namespaced_path': undefined method `name' for nil:NilClass (NoMethodError)
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.3/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb:21:in `fixture_name'
    from (erb):6:in `block in template'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:305:in `call'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:305:in `block in capture'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:310:in `with_output_buffer'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:305:in `capture'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.3/lib/rails/generators/named_base.rb:43:in `module_namespacing'
    from (erb):3:in `template'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/2.2.0/erb.rb:863:in `eval'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/2.2.0/erb.rb:863:in `result'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:116:in `block in template'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:53:in `call'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:53:in `render'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `block (2 levels) in invoke!'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `open'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `block in invoke!'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:116:in `call'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:116:in `invoke_with_conflict_check'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:60:in `invoke!'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions.rb:94:in `action'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:25:in `create_file'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:115:in `template'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.3/lib/rails/generators/named_base.rb:26:in `block in template'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.3/lib/rails/generators/named_base.rb:60:in `inside_template'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.3/lib/rails/generators/named_base.rb:25:in `template'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.3/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb:14:in `create_test_files'
    from /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run' 

This bug was introduced in #20387. It was my fault, sorry about this.

This commit fixes error, and adds a test for generated test files.

"%s_%s" % [namespaced_path, table_name]
else
table_name
end
end

def mountable?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this method needed in addition to mountable_engine?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a corresponding mistake. Fixed. Thanks!

@senny senny self-assigned this Jun 29, 2015
@senny senny added the railties label Jun 29, 2015
@senny
Copy link
Member

senny commented Jun 29, 2015

@y-yagi thanks for fixing the bug, especially for adding regression coverage on running these tests 💛!

@senny senny added this to the 4.2.4 milestone Jun 29, 2015
@senny senny merged commit b1738e1 into rails:master Jun 29, 2015
senny added a commit that referenced this pull request Jun 29, 2015
fix NoMethodError that occurs when generating scaffold inside full mode engine
senny added a commit that referenced this pull request Jun 29, 2015
fix NoMethodError that occurs when generating scaffold inside full mode engine

Conflicts:
	railties/CHANGELOG.md
	railties/test/generators/scaffold_controller_generator_test.rb
@senny
Copy link
Member

senny commented Jun 29, 2015

Backported to 4-2-stable (9360077)

@y-yagi
Copy link
Member Author

y-yagi commented Jun 29, 2015

@senny Thanks for reviewing!

@y-yagi y-yagi deleted the fix_scaffold_in_full_engine branch June 29, 2015 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants