Rails bug or breaking convention?

I had a unique instance where I needed a model called “MRA”. When I
built my scaffolded resource I get the following:

[email protected]:~/Documents/Projects/TestApp$ ruby script/generate
scaffold MRA
exists app/models/
exists app/controllers/
exists app/helpers/
create app/views/mr_as
exists app/views/layouts/
exists test/functional/
exists test/unit/
exists public/stylesheets/
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
create public/stylesheets/scaffold.css
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
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/20080614234404_create_mras.rb
[email protected]:~/Documents/Projects/TestApp$

Notice how it handled the controller and views file names. It split
the name of the Model because (I’m making an assumption) that it’s
treating the model like a name. So “Mr.” or “Mrs.”.

What’s worse, is if I try to continue working, I can’t create any more
scaffolded resources


[email protected]:~/Documents/Projects/TestApp$ ruby script/generate
scaffold Product
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:261:in load_missing_constant': Expected /home/ mwilliams/Documents/Projects/TestApp/app/helpers/mr_as_helper.rb to define MrAsHelper (LoadError) from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/ active_support/dependencies.rb:467:inconst_missing’
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/
active_support/dependencies.rb:479:in const_missing' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/ active_support/inflector.rb:283:inconstantize’
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/
active_support/core_ext/string/inflections.rb:143:in constantize' from /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/helpers.rb:133:inhelper’
from /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/helpers.rb:111:in each' from /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/helpers.rb:111:inhelper’
from /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/helpers.rb:116:in helper' ... 27 levels... from /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/commands/generate.rb: 1 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:ingem_original_require’
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require’
from script/generate:3
[email protected]:~/Documents/Projects/TestApp$

It even breaks migrations:

[email protected]:~/Documents/Projects/TestApp$ rake db:migrate
(in /home/mwilliams/Documents/Projects/TestApp)
rake aborted!
Expected /home/mwilliams/Documents/Projects/TestApp/app/helpers/
mr_as_helper.rb to define MrAsHelper

Is this a bug or is it breaking convention creating a model of all
capital letters (thought my case for creating an MRA model seems
legit).

I’ve created a ticket for the bug. Feel free to chime in or build a
patch (I may attempt to do so).

http://rails.lighthouseapp.com/projects/8994/tickets/408-generating-a-scaffold-resource-named-mr-confuses-breaks-the-generator#ticket-408-1

URL to the ticket…

On Jun 14, 7:49 pm, Matthew W. [email protected]