I'm trying to create this controller in Rails 4:
Admin::EDMsController
In my initializers/inflections.rb file, I've defined the acronym:
ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym 'EDMs'
inflect.acronym 'EDM'
end
My routes.rb file has:
namespace :admin do
# ... some other resources ...
resources :edms
end
And my controller is defined as follows in app/controllers/admin/edms_controller.rb:
class Admin::EDMsController < Admin::AdminController
end
When I try to access /admin/edms, I get the following error:
uninitialized constant Admin::EDMsController
What I've found so far:
It's also worth noting that I have other controllers and resources in the admin namespace which work correctly.
So it seems I can have an acronym controller, or a controller within a namespace, but not both.
Any suggestions?
Looks like this is a bug that was fixed in 4.2: https://github.com/rails/rails/pull/14146
If you can't upgrade, this should work:
irb(main):001:0> ActiveSupport::Inflector.inflections(:en) { |inflect| inflect.acronym 'Admin/EDMs' }
=> /Admin\/EDMs/
irb(main):002:0> 'Admin::EDMsController'.underscore
=> "admin/edms_controller"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With