という感じで、依存タスクとして:environmentを追加すると良い。 補足 単純にrequire '../../config/environment'としても一応可能だけど、テーブルが無かったりした場合に require に失敗してしまうのでよろしくない。 参考 Do rails rake tasks provide access to ActiveRecord models? - Stack Overflow Register as a new user and use Qiita more conveniently You get articles that match your needsYou can efficiently read back useful informationYou can use dark themeWhat you can do with signin