Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating model and index through one-line command?

I know I can easily create a model with this one line. Now suppose I want to add an index on username. How can I do so with one line without going to edit the migration file manually?

script/rails generate model TwitterUser username:string num_followers:integer num_following:integer bio:string location:string image:string num_tweets:integer website:string
like image 930
Henley Avatar asked Sep 16 '12 20:09

Henley


1 Answers

Rails version? New in 3.2, would be this:

rails generate model TwitterUser username:string:index num_followers:integer ...

You use scrip/rails generate so not sure if this helps you

like image 75
Tonys Avatar answered Oct 17 '22 07:10

Tonys