This project is archived and is in readonly mode.

#408 ✓wontfix
Matthew Williams

Generating a scaffold resource named MR* confuses/breaks the generator

Reported by Matthew Williams | June 13th, 2008 @ 04:02 PM

Generating a scaffold resource that begins with the characters "MR" wrongfully creates its associated files.

Example)

ruby script/generate scaffold MRA

exists app/models/

exists app/controllers/

exists app/helpers/

*strong*create app/views/mr_as*strong*

exists app/views/layouts/

exists test/functional/

exists test/unit/

exists public/stylesheets/

*strong*create app/views/mr_as/index.html.erb

create app/views/mr_as/show.html.erb

create app/views/mr_as/new.html.erb

create app/views/mr_as/edit.html.erb

create app/views/layouts/mr_as.html.erb*strong*

create public/stylesheets/scaffold.css

*strong*create app/controllers/mr_as_controller.rb

create test/functional/mr_as_controller_test.rb

create app/helpers/mr_as_helper.rb

route map.resources :mr_as*strong*

dependency model

exists app/models/

exists test/unit/

exists test/fixtures/

create app/models/mra.rb

create test/unit/mra_test.rb

create test/fixtures/mras.yml

create db/migrate

create db/migrate/20080613145050_create_mras.rb

As you can see above, the generator broke up the resources name with an underscore. This also prevents any further models from being generated. See below.

ruby script/generate scaffold product

c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:261:in `load_missing_constant': Expected C:/Projects/TestMRAMode

l/app/helpers/mr_as_helper.rb to define MrAsHelper (LoadError)

from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:467:in `const_missing'

from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:479:in `const_missing'

from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/inflector.rb:283:in `constantize'

from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/core_ext/string/inflections.rb:143:in `constantize'

from c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/helpers.rb:133:in `helper'

from c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/helpers.rb:111:in `each'

from c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/helpers.rb:111:in `helper'

from c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/helpers.rb:116:in `helper'

... 27 levels...

from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/commands/generate.rb:1

from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'

from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'

from script/generate:3

My assumption is that it's interpreting the string and seeing "MR" and treating that in some way as a persons title (which is why it breaks up the views to mr_a). The same thing happens when you generate a resource called "MRSTest".

This may be a feature I'm unaware of or that the convention is to not use all capital letters for a resource but in my case, I'm working with objects that happen to be called "MRAs".

I'd like to contribute so if I can come up with a patch over the weekend with some tests I will certainly attempt to do so.

Comments and changes to this ticket

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>

Pages