Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

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

#408

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.

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

State: wontfix
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Pratik
    Pratik
    • State changed from new to wontfix
    • Tag set to 2.1, bug, generator, model, resource, scaffold

    July 23rd, 2008 @ 02:05 PM

  2. Matthew Williams
    Matthew Williams

    Was this simply breaking convention which was the reason for "wontfix"?

    July 23rd, 2008 @ 02:09 PM

  3. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    October 11th, 2010 @ 10:57 AM