Helpers and assets not respecting acronyms inflections #14232

Closed
talski opened this Issue Feb 28, 2014 · 4 comments

Projects

None yet

4 participants

@talski
talski commented Feb 28, 2014

I've defined an acronym:

ActiveSupport::Inflector.inflections do |inflect|
  inflect.acronym 'RREO'
end

then I run the following rails generator:

rails g scaffold Contabilidade::RGF titulo:string ano:integer{2} semestre:integer{1} categoria:string descricao:text usuario_id:integer

but the result is not what I expected:

invoke  active_record
create    db/migrate/20140228190125_create_contabilidade_rreos.rb
create    app/models/contabilidade/rreo.rb
create    app/models/contabilidade.rb
invoke    test_unit
create      test/models/contabilidade/rreo_test.rb
create      test/fixtures/contabilidade/rreos.yml
invoke  resource_route
    route    namespace :contabilidade do
        resources :rreos
    end
invoke  scaffold_controller
create    app/controllers/contabilidade/rreos_controller.rb
invoke    erb
create      app/views/contabilidade/rreos
create      app/views/contabilidade/rreos/index.html.erb
create      app/views/contabilidade/rreos/edit.html.erb
create      app/views/contabilidade/rreos/show.html.erb
create      app/views/contabilidade/rreos/new.html.erb
create      app/views/contabilidade/rreos/_form.html.erb
invoke    test_unit
create      test/controllers/contabilidade/rreos_controller_test.rb
invoke    helper
create      app/helpers/contabilidade/rre_os_helper.rb
invoke      test_unit
create        test/helpers/contabilidade/rre_os_helper_test.rb
invoke  assets
invoke    js
create      app/assets/javascripts/contabilidade/rre_os.js
invoke    css
create      app/assets/stylesheets/contabilidade/rre_os.css
invoke  css
create    app/assets/stylesheets/scaffold.css

I was getting some correct "rreos" and some "rre_os" in helpers, test units and assets.

So, did i do something wrong?

@robin850
Member
robin850 commented Mar 2, 2014

Hello @talski,

Thanks for reporting the issue. It's an interesting problem because it's how Active Support is supposed to work. According to #acronym's documentation:

# The acronym, however, must occur as a delimited unit and not be part of
# another word for conversions to recognize it:
# ...
#   underscore 'HTTPS'           # => 'http_s', not 'https'

At the very least, even if the output should be rre_os, the file generated by Active Record aren't consistent with the other ones.

A quick workaround to make the output as you want would be to add:

inflect.acronym 'RREOs'

I think that we can't do so much to fix the problem here unless breaking existing inflections.

/cc @fxn

@talski
talski commented Mar 3, 2014

the files were correct created, but now i get a uninitialized constant Contabilidade::RREOsController

and there is a controller app/controller/contabilidade/rreos_controller.rb: class Contabilidade::RREOsController < ApplicationController

@rails-bot rails-bot added the stale label Aug 19, 2014
@rails-bot

This issue has been automatically marked as stale because it has not been commented on for at least
three months.

The resources of the Rails team are limited, and so we are asking for your help.

If you can still reproduce this error on the 4-1-stable, 4-0-stable branches or on master,
please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions.

@matthewd
Member
matthewd commented Oct 3, 2014

I think this is a duplicate of #8015, which means it should be fixed in master since ccbb481

@matthewd matthewd closed this Oct 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment