I''d really appreciate it if someone [with a decent understanding of the
rails Dependencies mechanism] could help me explain the behaviour seen
in this pastie.
http://pastie.caboo.se/46630
The desired behaviour is simply aliasing a method in
ApplicationController from a plugin while retaining automatic reloading
in dev mode.
The pastie is basically divided into 4 parts:
- Setup of rails app and initial version of
app/controllers/application.rb
- Setup of plugin which will alias the method in application.rb and
initial attempt without loading ''application''
The interesting parts (for me) are the last two frames:
Firstly, I use require_dependency to load ApplicationController but as
you can see the aliasing doesn''t work (funnily enough the xxx_with/out
methods are defined).
Secondly, I use ''require'' to load ApplicationController and
here
aliasing works as it should but I''m losing reloading of application.rb.
The same behaviour is observed if I use the following module included
method:
#speaker plugin init.rb
#require ''application''
require_dependency ''application''
module Speaker
def self.included(base)
base.alias_method_chain :say_hello, :speaker
end
protected
def say_hello_with_speaker
puts "Hello speaker...."
end
end
ApplicationController.send(:include, Speaker)
Any help heres is much appreciated...
Regards,
Saimon
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---