Load and use fixture in rails console

前端 未结 6 1822
南方客
南方客 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条回答
  •  梦谈多话
    2021-01-31 09:02

    You can load a fixture in the Rails 3.2 console as follows:

    require 'active_record/fixtures'
    
    ActiveRecord::Fixtures.create_fixtures FIXTURE_PATH_HERE, MODEL_NAME_HERE
    

提交回复
热议问题