15

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
Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
Henley
  • 21,258
  • 32
  • 119
  • 207

1 Answers1

28

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

Tonys
  • 3,349
  • 4
  • 24
  • 27
  • Yes, as blogged by Jose Valim [here](http://blog.plataformatec.com.br/2012/01/my-five-favorite-hidden-features-in-rails-3-2/) – Christian Sep 16 '12 at 22:06