Reputation: 25
I'm trying to generate a new user model, and I could have sworn that this worked before
$ rails generate migration User.rb
but now it complains that this is illegal. I keep getting an error:
Illegal name for migration file: user.rb (only lower case letters, numbers, and '_' allowed)
As you can see user.rb is only lowercase.
Upvotes: 1
Views: 1520
Reputation: 15992
Actually, issue here is with .
which you have between User
and rb
, i.e.: User.rb
. If you change it to: rails generate migration Userrb
then it should work.
However, you can be more efficient while generating a migration by following a small convention:
To create users table:
$ rails generate migration create_users
or:
$ rails generate migration CreateUsers
To have some columns while creating users table:
$ rails generate migration create_users name:string email:string address:text
or:
$ rails generate migration CreateUsers name:string email:string address:text
UPDATE: Apologies for not consider your line: generate a new user model. If you want to generate a model then you can run these convenient commands:
To create User model which will also create users table migration by default:
$ rails generate model user
or:
$ rails generate model User
To create User model which will also create users table migration with some attributes by default:
$ rails generate model user name:string email:string address:text
or:
$ rails generate model User name:string email:string address:text
Upvotes: 4