Search code examples
ruby-on-railsruby-on-rails-5rails-routing

'sarlLegalStatuses' is not a supported controller name


I'm struggling with the following error when using the camelcased version of my ressource named sarlLegalSatuses

this is the error i get :

in check_controller_and_action': 'sarlLegalStatuses' is not a supported controller name. This can lead to potential routing problems.

my routing :

ils.application.routes.draw do
  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
  root 'sarlLegalStatuses#new'

  resources :sarlLegalStatuses
end

Using snake case fixed the issue, but as I'm going further in the code, this start to be quite annoying. I noticed people havinf problem with plural forms of words ending with "s" so I added the following inflections without success, as you can see :

Acti

veSupport::Inflector.inflections(:en) do |inflect|
  #   inflect.acronym 'RESTful'
  inflect.uncountable %w(sarl legal)
  inflect.irregular 'status', 'statuses'
end

What is wrong ?


Solution

  • The wrong thing here is you try to go against Ruby on Rails convention. Stick to the RoR convention, use snake case in your routes:

    root 'sarl_legal_statuses#new'
    resources :sarl_legal_statuses
    

    and you'll be all right. What's more, the code will be more friendly for those who might enter the project in the future. So the experiments with camel case are completely pointless.