Extending controllers of a Rails 3 Engine in the main app -


i using rails engine gem in app. engine has postscontroller number of methods , extend controller logic in main app, e.g. add methods. if create postscontroller in main app, engine's controller not loaded.

there solution proposed in question rails engines extending functionality based on altering activesupport::dependencies#require_or_load

is only/correct way this? if yes, put piece of code?

edit1:

this code suggested andrius rails 2.x

module activesupport::dependencies   alias_method :require_or_load_without_multiple, :require_or_load   def require_or_load(file_name, const_path = nil)     if file_name.starts_with?(rails_root + '/app')       relative_name = file_name.gsub(rails_root, '')       @engine_paths ||= rails::initializer.new(rails.configuration).plugin_loader.engines.collect {|plugin| plugin.directory }       @engine_paths.each |path|         engine_file = file.join(path, relative_name)         require_or_load_without_multiple(engine_file, const_path) if file.file?(engine_file)       end     end     require_or_load_without_multiple(file_name, const_path)   end end 

why not inherit engine's controller class in application (and point routes @ new child controllers)? sounds conceptually similar way extend built-in devise controllers.


Comments

Popular posts from this blog

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

apache - Add omitted ? to URLs -

php - How can I stop spam on my custom forum/blog? -