Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
778 views
in Technique[技术] by (71.8m points)

ruby on rails - How can I force my plugin to reload with each request?

As I understand it, plugins are not reloaded in Rails with each request in development mode. Which makes sense, as generally you add plugins to your app and it's the app you're developing.

But if you are developing a plugin, you have to restart the server with each change to the plugin which has a significant overhead.

Is there any way to make Rails reload your plugin during development, the way it reloads your models and controllers?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I have been struggling with this for some time, too. None of the solutions work, including the autoload_paths and autoload_once_paths tricks. Furthermore, the hack with FileUpdateChecker and initializers also does not help (the checker triggers properly, but the files are not reloaded). Same for config.reload_plugins = true...

However, there is a solution. In app/controllers/application_controller.rb add one line: require_dependency 'your_file_name_here' The application controller is reloaded on every request and require_dependency makes your file to be checked for modifications and reloaded accordingly. It worked for me, Apache 2, Passenger 3 and Rails 3.0.3.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...