Load and use fixture in rails console

前端 未结 6 1894
南方客
南方客 2021-01-31 08:07

I wonder if there\'s a way to load and/or use fixture in rails console. Actually, I\'d like to create a user from my fixture users.yml to do some testing without ha

6条回答
  •  旧时难觅i
    2021-01-31 08:43

    You can load fixtures into your development database too:

    $ rake db:fixtures:load
    $ rails c
    > require 'active_record/fixtures'
    > john = User.find ActiveRecord::FixtureSet.identify('john')
    

提交回复
热议问题