开发者

Is there a way to configure rails console to re-run my initializers?

I have code in my application.rb f开发者_运维技巧ile, that calls class methods that load certain objects into memory. If I am in rails console and have to use "reload!" those objects are no longer in memory, and i have to quit and restart rails c.

This is the code for those initializers:

config.to_prepare do
    Const.load!
    Card.load!
    Position.load!
end

Note that this is different than just reloading an object that changes in lib, which I have seen answers on how to do.


in your application.rb try this:

ActionDispatch::Callbacks.after
  Const.load!
  Card.load!
  Position.load!
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜