I created a rails application with the following command:
rails new Education
Now, I am trying to create a new model in rails with the following command:
rails generate model Education name:string
When running it it returns the following error:
The name 'Education' is either already used in your application or reserved by Ruby on Rails. Please choose an alternative and run this generator again.
Since I just created a new app and only have one other model and I have a hard time thinking about any reason why Rails would reserve a name like that?
Any thoughts on where this error comes from and how I can work around it?
(I have tried changing the name to something else and it works as expected. Since the name really fits its purpose I don't want to change its name unless there is no other way!)
I am using Ruby 2.0.0 with Rails 4.0.0 and PostgreSQL
You may not create a model with the same name as the Application because it will create conflicting names. When you create an application i.e. rails new Education
it will create a module named Education
as follows
module Education
class Application < Rails::Application
#....
end
end
This named module is then called in files such as config.ru
, routes.rb
and environment.rb
and many more. So if you were able to create a model class by the same name it would create ambiguity as to whether you were calling the Model or the Module.