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:
using ‘alias_method chain’ : find_plugins, :engine_additions
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
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.
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:
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:
route in app’s route.rb (complains that controller is not found)
route and controller in main app (complains view isn’t there)
route.rb in root of plugin (no special route loaded)
added the map.from_plugin :my_plugin in the main app’s route.rb (no
special route loaded)
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:
Need to put a new ‘connect’ mapping above the default routes for
entire
app
Need to create a special controller to handle the RCSSs
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?
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:
route in app’s route.rb (complains that controller is not found)
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.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.