Reputation: 304
The error I get in console when attempting to run "rails generate controller" is:
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-
4.0.2/lib/action_dispatch/routing/mapper.rb:239:in `default_controller_and_action': 'Pages' is not a supported controller name.
The line I am trying to run is:
rails generate controller Pages home rules schedule forum register scrims
Can anybody elaborate as to why this is? I haven't been able to figure it out on my own.
Any help would be greatly appreciated.
Upvotes: 0
Views: 1311
Reputation: 3583
I remember I had the same and I guess you've changed ruby/rails versions in the Gemfile.
Create new project and check there - check if it's fine.
When you do rails new project
with one version of Rails than you cannot just do that to upgrade as you already have framework directories/files for the old version.
Upvotes: 0
Reputation: 304
The answer was to re-install the entire rails suite and ruby... Tedious but it fixed the issue.
Upvotes: 0
Reputation: 37409
You should call your generate methods with the naming conventions of snake_case
, meaning:
rails generate controller pages
is good, but
rails generate controller Pages
is bad. See remark here:
Only the directory notation is supported. Specifying the controller with ruby constant notation (
eg. :controller => 'Admin::UserPermissions'
) can lead to routing problems and results in a warning.
and the code throwing the exception here:
if controller.is_a?(String) && controller !~ /\A[a-z_0-9\/]*\z/
message = "'#{controller}' is not a supported controller name. This can lead to potential routing problems."
message << " See http://guides.rubyonrails.org/routing.html#specifying-a-controller-to-use"
raise ArgumentError, message
end
Upvotes: 2