Configuration/Initialization question

Hi,

Maybe I’m overseeing something, what is the right place to put
Engines. (eg public paths) so that it is correctly used
? (or more generally MyPlugin.config; so that init.rb of my plugin
behaves differently on startup if I’m running in dev mode or prod mode )

If I put in environment.rb before the initializer it says Engines
constant is missing (because plugins are not loaded yet)

If I put it after the initializer block it’s too late …

regards,

Bart

NEW on aXs GUARD: SSL VPN !! (contact your reseller for more info)


aXs GUARD has completed security and anti-virus checks on this e-mail
(http://www.axsguard.com)

Able NV: ond.nr 0457.938.087
RPR Mechelen

I believe you’ll want to put it in the config.after_initialize block,
somehow.

James A. wrote:

I believe you’ll want to put it in the config.after_initialize block, somehow.

That doesn’t seem to do the trick; the engine plugin is loaded and
init’ed before after_initialize. So the files are copied to the
public_directory specified in the Engines module itself and not to my
specified directory setting.

regards,

Bart

Ah,

Sorry - I think I misunderstood what you were trying to achieve. In
general, there’s no simple way to set the options for a plugin before
it has loaded. If you need a plugin to have some options set and
then do something, init.rb probably isn’t the place to achieve this.
Instead, I’d develop your plugin such that things can happen at the
end of environment.rb:

MyPlugin.option_one = :something
MyPlugin.option_two = [1,2,3,4]
MyPlugin.ok_now_get_ready()

It sounds like you’re trying to do something with the public asset
copying facilities; in this case, you should be able to re-set the
Engines.public_directory parameter at the bottom of environment.rb
file, and then call
Rails.plugins[:your_plugin_name].mirror_plugin_assets. That might do
what you hope.

What is it that you’re specifically trying to do?

James A. wrote:

MyPlugin.option_two = [1,2,3,4]
MyPlugin.ok_now_get_ready()

It sounds like you’re trying to do something with the public asset
copying facilities; in this case, you should be able to re-set the
Engines.public_directory parameter at the bottom of environment.rb
file, and then call
Rails.plugins[:your_plugin_name].mirror_plugin_assets. That might do
what you hope.

ok, this makes sense. By studying the initializer code I already came to
the same conclusion but maybe I was overlooking some meta-added
functionality.
Or we need to modify the configuration class to add plugin specific
options or do it like you say above.
To be honest I was just using the public_path example as a ‘placeholder’
for my questions, what I’m really trying to do is explained below.

What is it that you’re specifically trying to do?

Well I added an option to the engines plugin to symlink the public files
instead of copy them. So I added Engines.symlink_asset_files boolean to
the module and used it in the
Engines.mirror_files_from.
In development mode I want to symlink (because some of the plugins I’m
developing contain assets that get modified during the development
process of the main application), in production mode I want to copy
that’s why I wanted to change the setting in config/environment.
Maybe there is another way of achieving what I want; basically I want to
have full flexibility in development mode with as least restarting as
possible. Is it possible to execute mirror_plugin_assets before every
request get’s handled in development mode ?

Oh and BTW thanks for the great engines +plugin+ you made.

regards

bart

On Mon, Aug 27, 2007 at 01:39:35PM +0200, Bart D. wrote:

possible. Is it possible to execute mirror_plugin_assets before every
request get’s handled in development mode ?

This sounds rather overcomplicated to me. I use symlinks too, and this
works
fine even without making any configuration changes. Maybe I’m
misunderstanding
what you’re trying to do, but I’ll explain how I do it:

If I have a project called ‘myproject’, in my plugin_assets directory I
create a symlink by that name to the assets directory in the plugin:
$ cd public/plugin_assets
$ ln …/…/vendor/plugins/myproject/assets myproject

There’s no need to do anything more than this, afaik.

Regards,
Peter B.
Solide ICT - http://www.solide-ict.nl

Peter B. wrote:

Maybe there is another way of achieving what I want; basically I want to
create a symlink by that name to the assets directory in the plugin:
$ cd public/plugin_assets
$ ln …/…/vendor/plugins/myproject/assets myproject

There’s no need to do anything more than this, afaik.

:-[
You’re right; shame on me; things can really be simple sometimes …

thx

Bart

On 8/27/07, Bart D. [email protected] wrote:

You’re right; shame on me; things can really be simple sometimes …

The other simple approach would be to attach some behaviour to the
dispatcher which calls mirror_public_files before every request - see
the “to_prepare” method in the rails’ Dispatcher for more details :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs