Hi there, I''m currently developing a plugin to do authentication and authorisation. In the init.rb file of the plugin I have this code:- $:.unshift File.expand_path(File.join(File.dirname(__FILE__), ''lib'')) require ''open_advantage/authorisation'' ActionController::Base.send :include, OpenAdvantage::Authorisation and this is the skeleton of my plugin directory structure:- vendor/plugins/open_advantage/init.rb vendor/plugins/lib/open_advantage/authorisation.rb the ''vendor/plugins/lib/open_advantage/authorisation.rb'' file contains module OpenAdvantage module Authorisation end end currently with only a few methods in the Authorisation module. However, when I change one of the functions in this module the function is not mirrored in the output of the web browser. For example if I deliberately make a mistake in the code it carrys on as before when it should presumably raise a ''Come on, FFS this is nonsensical rubbish'' error. It continues to do this until the web server (either lighttpd or webrick, I''ve tried both) are restarted. Is there someway I can make the changes I''ve made in my plugin immediately available to the application? I''ve tried putting various require and include statements into the app/controllers/ application.rb file, but to no avail. The only way I can find for it to pick up the changes every time is to pop the classes in the app/ controllers/application.rb file, and I''d really rather not develop like that. Any help would be gratefully received. Thanks, Anthony
Hello Anthony ~ For changes in a plugin to be picked up the app needs to be restarted. Imagine if the app had to reload every plugin on every request in development mode? It would be quite a long wait for apps with many plugins... Don''t know if you saw this, but Geoffrey Grosenbach just released this: http://nubyonrails.com/articles/2006/05/04/the-complete-guide-to-rails-plugins-part-i It might have some tips. ~ Ben On 5/5/06, Anthony Ramm <anthony@openadvantage.org> wrote:> Hi there, > > I''m currently developing a plugin to do authentication and > authorisation. In the init.rb file of the plugin I have this code:- > $:.unshift File.expand_path(File.join(File.dirname(__FILE__), ''lib'')) > require ''open_advantage/authorisation'' > ActionController::Base.send :include, OpenAdvantage::Authorisation > > and this is the skeleton of my plugin directory structure:- > vendor/plugins/open_advantage/init.rb > vendor/plugins/lib/open_advantage/authorisation.rb > > the ''vendor/plugins/lib/open_advantage/authorisation.rb'' file contains > module OpenAdvantage > module Authorisation > end > end > currently with only a few methods in the Authorisation module. > However, when I change one of the functions in this module the > function is not mirrored in the output of the web browser. For > example if I deliberately make a mistake in the code it carrys on as > before when it should presumably raise a ''Come on, FFS this is > nonsensical rubbish'' error. It continues to do this until the web > server (either lighttpd or webrick, I''ve tried both) are restarted. > > Is there someway I can make the changes I''ve made in my plugin > immediately available to the application? I''ve tried putting various > require and include statements into the app/controllers/ > application.rb file, but to no avail. The only way I can find for it > to pick up the changes every time is to pop the classes in the app/ > controllers/application.rb file, and I''d really rather not develop > like that. > > Any help would be gratefully received. > > Thanks, > > Anthony > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Ben Reubenstein 303-947-0446 http://www.benr75.com
Hi Anthony, while you are developing your plugin (and want reloading capability) you could move the ''require'' and ''include'' lines from init.rb into your ApplicationController (app/controllers/application.rb). Assuming all other controllers inherit from this controller the results ought to be the same. You''ll need to change the ''require'' to ''require_dependency'' but apart from that it should be fine. Regards, Trevor -- Trevor Squires http://somethinglearned.com On 5-May-06, at 4:01 PM, Anthony Ramm wrote:> Hi there, > > I''m currently developing a plugin to do authentication and > authorisation. In the init.rb file of the plugin I have this code:- > $:.unshift File.expand_path(File.join(File.dirname(__FILE__), ''lib'')) > require ''open_advantage/authorisation'' > ActionController::Base.send :include, OpenAdvantage::Authorisation > > and this is the skeleton of my plugin directory structure:- > vendor/plugins/open_advantage/init.rb > vendor/plugins/lib/open_advantage/authorisation.rb > > the ''vendor/plugins/lib/open_advantage/authorisation.rb'' file contains > module OpenAdvantage > module Authorisation > end > end > currently with only a few methods in the Authorisation module. > However, when I change one of the functions in this module the > function is not mirrored in the output of the web browser. For > example if I deliberately make a mistake in the code it carrys on > as before when it should presumably raise a ''Come on, FFS this is > nonsensical rubbish'' error. It continues to do this until the web > server (either lighttpd or webrick, I''ve tried both) are restarted. > > Is there someway I can make the changes I''ve made in my plugin > immediately available to the application? I''ve tried putting > various require and include statements into the app/controllers/ > application.rb file, but to no avail. The only way I can find for > it to pick up the changes every time is to pop the classes in the > app/controllers/application.rb file, and I''d really rather not > develop like that. > > Any help would be gratefully received. > > Thanks, > > Anthony > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Hi again Anthony, OOPS! I wasn''t very clear, I''ll give an example: in app/controllers/application.rb class ApplicationController < ActionController::Base require_dependency ''open_advantage/authorization'' include OpenAdvantage::Authorization end Oh, and by the way, the correct directory structure is: vendor/plugins/open_advantage/init.rb vendor/plugins/open_advantage/lib/open_advantage/authorization.rb That way, you can get rid of the $:.unshift code. Begin forwarded message:> From: Trevor Squires <trevor@protocool.com> > Date: May 5, 2006 7:05:47 PM PDT (CA) > To: rails@lists.rubyonrails.org > Subject: Re: [Rails] Plugin refresh time > > Hi Anthony, > > while you are developing your plugin (and want reloading > capability) you could move the ''require'' and ''include'' lines from > init.rb into your ApplicationController (app/controllers/ > application.rb). Assuming all other controllers inherit from this > controller the results ought to be the same. > > You''ll need to change the ''require'' to ''require_dependency'' but > apart from that it should be fine. > Regards, > Trevor > -- > Trevor Squires > http://somethinglearned.com > > On 5-May-06, at 4:01 PM, Anthony Ramm wrote: > >> Hi there, >> >> I''m currently developing a plugin to do authentication and >> authorisation. In the init.rb file of the plugin I have this code:- >> $:.unshift File.expand_path(File.join(File.dirname(__FILE__), >> ''lib'')) >> require ''open_advantage/authorisation'' >> ActionController::Base.send :include, OpenAdvantage::Authorisation >> >> and this is the skeleton of my plugin directory structure:- >> vendor/plugins/open_advantage/init.rb >> vendor/plugins/lib/open_advantage/authorisation.rb >> >> the ''vendor/plugins/lib/open_advantage/authorisation.rb'' file >> contains >> module OpenAdvantage >> module Authorisation >> end >> end >> currently with only a few methods in the Authorisation module. >> However, when I change one of the functions in this module the >> function is not mirrored in the output of the web browser. For >> example if I deliberately make a mistake in the code it carrys on >> as before when it should presumably raise a ''Come on, FFS this is >> nonsensical rubbish'' error. It continues to do this until the web >> server (either lighttpd or webrick, I''ve tried both) are restarted. >> >> Is there someway I can make the changes I''ve made in my plugin >> immediately available to the application? I''ve tried putting >> various require and include statements into the app/controllers/ >> application.rb file, but to no avail. The only way I can find for >> it to pick up the changes every time is to pop the classes in the >> app/controllers/application.rb file, and I''d really rather not >> develop like that. >> >> Any help would be gratefully received. >> >> Thanks, >> >> Anthony >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060506/8fb02347/attachment.html