How (and whether) to populate rails application with initial data

后端 未结 13 1670
隐瞒了意图╮
隐瞒了意图╮ 2020-12-04 05:43

I\'ve got a rails application where users have to log in. Therefore in order for the application to be usable, there must be one initial user in the system for the first pe

相关标签:
13条回答
  • 2020-12-04 06:37

    Consider using the rails console. Good for one-off admin tasks where it's not worth the effort to set up a script or migration.

    On your production machine:

    script/console production
    

    ... then ...

    User.create(:name => "Whoever", :password => "whichever")
    

    If you're generating this initial user more than once, then you could also add a script in RAILS_ROOT/script/, and run it from the command line on your production machine, or via a capistrano task.

    0 讨论(0)
提交回复
热议问题