每当我想打开Rails控制台时,我都厌倦了写这行:
irb(main):001:0> ActsAsTenant.current_tenant = User.find(1).account在每次"rails c"/"irb“调用之前是否有任何方法运行命令/脚本?
提前感谢!
发布于 2018-07-20 15:32:14
我写了一个在另一个问题中扩展了对这个问题的回答,但简单的回答是,如果您是使用Rails 3或以上,可以在YourApp::Application上使用控制台方法来实现:
module YourApp
class Application < Rails::Application
...
console do
ActsAsTenant.current_tenant = User.find(1).account
end
end
endhttps://stackoverflow.com/questions/35772589
复制相似问题