Hey all. I’m making use of Engines-based plugins in several of my
sites. I have a wiki, a login engine, a CRM tool… Right now, I
install the plugin(s), then have to create a mask controller containing
a layout “standard-layout” call, and that’s it. This would seem to be a
common problem for any engine-type plugin that aims to integrate with
(rather than live separately from) the main app.
Is there a better solution that I’m not seeing with existing code?
Assuming there isn’t (I’ve looked), what would people think about
patching in support to the layout system of Rails to support an
application-wide default layout? The Rails docs mention using
“application.rhtml” as a way to achieve this, but it doesn’t work, and
there’s no code in place to support it in the latest stable release that
I can find.
Thoughts?
Simply creating an application.rhtml file inside of your base
application’s app/views/layouts directory should certainly do the
trick. When doing that you don’t need to specify a ‘layout’ directive
in your controllers since that’s the default. I’m doing this
currently in my application and it too uses engine plugins. No
problems.
Cheers,
Aaron
On 5/9/07, Rob M. [email protected] wrote:
Assuming there isn’t (I’ve looked), what would people think about patching
http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org
–
Aaron Campos
[email protected]
skype & AOL IM: aaroncampos
Aaron, what version of Rails are you running? I’m using 1.2.3 and
adding an application.rhtml doesn’t have any effect. I looked through
the render() and layout code in the codebase, looking for an
application.* default, and couldn’t find it. Is it possible you’re
running an older version of Rails, and that the current rev has dropped
that feature, for some reason?
-Rob
On 5/9/07, Rob M. [email protected] wrote:
Aaron, what version of Rails are you running? I’m using 1.2.3 and adding
an application.rhtml doesn’t have any effect. I looked through the render()
and layout code in the codebase, looking for an application.* default, and
couldn’t find it. Is it possible you’re running an older version of Rails,
and that the current rev has dropped that feature, for some reason?
Hi Rob,
Sorry for the delayed response. Nope, I’m using Rails 1.2.3. Perhaps
reading through the layout section in the API doc will help:
http://api.rubyonrails.org/classes/ActionController/Layout/ClassMethods.html#M000129
HTH,
Aaron
–
Aaron Campos
[email protected]
skype & AOL IM: aaroncampos
– Find me at RailsConf –
On 7/27/07, Rob M. [email protected] wrote:
How do I figure out, safely and consistently, that a given plugin
has been installed? I seem to recall some sort of list being maintained
by Rails, but couldn’t find where I read about it. Is there such a
list? When does it get initialized?
The engines plugin, for Rails 1.2, created an array of all the loaded
plugins, accessible via “Rails.plugins”. This is a list of every
plugin that was loaded (and reflects the order they were loaded too).
This list is set up as soon as the engines plugin loads, and is then
built by the Rails::Initializer extensions that the engines plugin
provides.
Rails.plugins is actually a PluginList, which means that you can do
Rails.plugins.first
Rails.plugins[0]
Rails.plugins[:plugin_name]
Rails.plugins[“plugin_name”]
… and they all will return the plugin at the given index, or with
the given name.
Second question:
I'm planning on creating the relationships using polymorphic
associations. Is there a smarter/better way to do this? Has anyone
tried cross-plugin associations?
You should be able to do this, as long as Plugin A doesn’t need to
actually load or instantiate any of the models from Plugins B before
Plugin B has loaded. Any kind of inter-plugin-dependency will need
careful management to ensure that code isn’t eagerly loaded while the
plugins are loading.
HTH,
James
Hey smart people. I’m trying to solve a problem I am sure has been
solved by someone out there already, and am hoping one of them is on
this list.
Here goes, as simply as I can make it:
I am building a set of engine-ized plugins for core services I want to
reuse (like C++ libraries). So, for example, I have a calendar plugin,
a user management plugin, a file management plugin…
I want to have relationships between these plugins, for example, have a
User optionally has_one() a Calendar. This should only happen if the
calendar plugin is installed.
So, first question:
How do I figure out, safely and consistently, that a given plugin
has been installed? I seem to recall some sort of list being maintained
by Rails, but couldn’t find where I read about it. Is there such a
list? When does it get initialized?
Second question:
I'm planning on creating the relationships using polymorphic
associations. Is there a smarter/better way to do this? Has anyone
tried cross-plugin associations?
Thanks for any thoughts/advice on this. I’m really enjoying the
functionality the engines plugin provides. (Thanks, James!)
-Rob M.