Hi, I have been developing a Rails plugin recently, and I have realised that for every change I make into files of my plugin, I have to restart the server to make changes take effect. While changes at application's own file appear instantly. I'm writing only after I searched for an answer over web but didn't find any. It's getting irritating now. -thanks
on 2009-07-03 20:04
on 2009-07-03 21:33
Vikrant wrote: > Hi, > I have been developing a Rails plugin recently, and I have realised > that for every change I make into files of my plugin, I have to > restart the server to make changes take effect. While changes at > application's own file appear instantly. > I'm writing only after I searched for an answer over web but didn't > find any. It's getting irritating now. > > -thanks I think it comes down to what type of plugin you are using first of all. If the plugin communicates with a database or something that can change dynamically then it can be done. You can specify a configs environment with your plugin for how it behaves via option types. Load those in a database and have an admin page that changes the way it works there. I do this with a CMS plugin I created for my site.
on 2009-07-04 08:25
No, you didn't understand. What I'm telling is, while I'm coding in "development" mode, if I change something in "app/controllers/application_controller.rb", changes appear instantly. But if I change something in "vendor/plugins/ my_plugin/lib/example.rb", I need to restart the server for changes to take effect. (even in "development" mode). In other words, applications files get reloaded on every request, while plugin files load only once and stay in memory. How can I make sure that plugin files also reload with every request? - thanks On Jul 4, 12:33 am, "Älphä Blüë" <rails-mailing-l...@andreas-s.net>
on 2009-07-04 08:33
I have this in my development.rb file, which I set up when I was making
some changes to a thirdparty plugin and got sick of the constant
restarting.
# this forces the Ezgraphix plugin to be reloaded each time - to
facilitate 'fixing' and updating it
Dependencies.explicitly_unloadable_constants << 'Ezgraphix'
["ezgraphix"].each do |plugin_name|
reloadable_path = RAILS_ROOT + "/vendor/plugins/#{plugin_name}/lib"
Dependencies.load_once_paths.delete(reloadable_path)
end
Cheers
Simon
on 2009-07-04 08:54
Thanks Simon Macneall, It worked!! I hope you mean ActiveSupport::Dependencies by Dependencies otherwise I get an error `const_missing':NameError: uninitialized constant Rails::Initializer::Dependencies. I first tried only to write ActiveSupport::Dependencies.load_once_paths.delete RAILS_ROOT + '/ vendor/plugins/my_plugin/lib' but that didn't work out, so I changed it too - ActiveSupport::Dependencies.explicitly_unloadable_constants << 'MyPlugin' ActiveSupport::Dependencies.load_once_paths.delete RAILS_ROOT + '/ vendor/plugins/my_plugin/lib' - thanks for your answer.
on 2009-07-04 08:57
Your welcome. The differences probably mean we are using different versions of Rails. Cheers Simon
on 2009-07-04 11:38
Hi - Why not develop the plugin in your app's /lib directory first? Once you're happy with how it works, you can transfer it over to the plugin's /lib directory That way you don't have to restart the server or change your apps configuration options Gavin http://handyrailstips.com/
on 2009-07-04 15:31
Gavin Morrice wrote: > Hi - Why not develop the plugin in your app's /lib directory first? > > Once you're happy with how it works, you can transfer it over to the > plugin's /lib directory > > That way you don't have to restart the server or change your apps > configuration options > > Gavin > > http://handyrailstips.com/ That's exactly what I was going to suggest. I have several lib files I develop parsers with and other app factorization methods with that I will eventually place into a plugin for later use. As I'm in development, I keep them there so I can change and keep going along. Plugins are for finished pieces that you want to use in multiple projects. If you are developing something that will be used in multiple projects, get it working first and then create a plugin for it. Otherwise, if it's just a one-off type of deal, keep it internal..
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.