Hi guys, I am a member of Steve's team (he posted last month about the 1.2 branch). 1st Thanks for the amazing work to James! Engines is an amazing piece of work. To the question then: I would need to be able to override a Rails Initializer method (find_plugins). I noticed that the rails_initializer.rb file contains the Engine::RailsExtensions::RailsInitializer which, according to its leading comment, attempts to override 3 Initializer methods. I therefore tried to put my "modified" version of find_plugins using the conventions found in the Engine::RailsExtensions::RailsInitializer: 1. using 'alias_method chain' : find_plugins, :engine_additions 2. writing a method called 'find_plugins_with_engine_additions' with a slightly modified body. The problem is that it doesn't seem to be invoked at any time (neither does the 'load_plugin_with_engine_addition). Could you let me know how and where it should be invoked / included to overwrite this Initializer method Thanks!
on 2007-02-20 19:25
on 2007-02-21 10:56
Hi Hugo, Using alias_method_chain is normally quite easy, but if you're doing it from within a module you need to be sure that the "alias_method_chain" call is made on the base class when it's included - see the top of engines/lib/engines/rails_extensions/rails_initializer.rb for an example - I'm using base.class_eval to make the calls to alias_method_chain as if they were in the including class itself. My guess is that it's something like this which is stopping your methods being called - have a play around and if you're still not making any progress, email us the code and we'll take a look. Cheers and thanks for the nice comments :) James
on 2007-02-22 01:33
Hey James, Thanks for the tips. Actually my problem was resolved using a combination of alias_method_chain and config.plugin = [ "engine", "*"]. I ran into another small problem ... Trying to use another application that I built as a plugin, I found that the stylesheets don't get loaded. I tried to invoke them using <%= "engine_stylesheet 'stylesheet' %> but that returns an error saying that engine_stylesheet is undefined... Any clues? Thanks Hugo
on 2007-02-22 11:15
Hi Hugo, Are you using the engines 1.2 release? If so, check the UPGRADING file.... - James
on 2007-02-22 21:04
Thanks James, the :plugin => "my_plugin" did it. Another quick question. I am running into an issue with my CSSs which are refering to images... obviously when the plugin gets loaded the CSS image URL doesn't hold any longer. I figured using RCSS might help fix this (since I can use the image_tab="image", plugin => "plugin" notation to refer to images) BUT the some of the RCSS techiques I've looked at use a special route: map.connect 'rcss/:rcss.:format', :controller => 'rcss', :action => 'dispatch' So putting this route in a stand alone app works fine, but once I try to refer to rcss files located in the view/rcss folder of my plugin all hell breaks loose. The comment by the technique author is that this route statement should go before the default routes in the app's route.rb What I tried: 1. route in app's route.rb (complains that controller is not found) 2. route and controller in main app (complains view isn't there) 3. route.rb in root of plugin (no special route loaded) 4. added the map.from_plugin :my_plugin in the main app's route.rb (no special route loaded) Thanks James!
on 2007-02-24 04:21
Hey, Maybe my question is not formulated right. Here's a second try: I'd like to use RCSS-stylesheets instead of regular CSS-stylesheets. What this implies: 1. Need to put a new 'connect' mapping above the default routes for entire app 2. Need to create a special controller to handle the RCSSs 3. Need to move the RCSSs to the view folder The problem: The RCSS files don't seem to appear to the application when the RCSSsed app is used as a plugin. A thing I'm not sure about: In routing.rb there is a mention that on should add a 'map.from_plugin:your_plugin' call in a 'ApplicationController::Routing::Routes.draw do |map|...' block Where should this block go? Thanks, Hugo
on 2007-02-27 13:59
On 2/24/07, Hugo Levasseur <levasseur.hugo@gmail.com> wrote: > A thing I'm not sure about: > In routing.rb there is a mention that on should add a 'map.from_plugin > :your_plugin' call in a > 'ApplicationController::Routing::Routes.draw do |map|...' > block > Where should this block go? This is the code which is in your main config/routes.rb file. Essentially it's talking about including ruotes defined within plugins into your routing. However, it may not be necessary to include any special routes. The problems seem clearer in your earlier mail: > 1. route in app's route.rb (complains that controller is not found) > 2. route and controller in main app (complains view isn't there) It seems like the controller isn't being loaded from the plugin, when clearly it should be. Check the log output from the engines plugin, and the load paths for the routing system to be sure that your plugin is loaded and the controller can be found.
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.