M@'s Musings

« Back to blog
 

Rails Theme Support Plugin



Update: I changed the svn URL to point to it's new home!


Currently, to add support for themes into your rails application, you have to install the theme_generator. The generator will then create the folder structure for themes, and it also creates the plugin files for theme support in rails.


The more I've thought about it, the less I like this approach. I'd rather have a fully encapsulated plugin that would add support for themes into rails and define a simple generator that would merely create the boilerplate theme structure.


To that end, I present the Rail Theme Support plugin. To install the plugin execute the following in the root of your application (requires rails 0.14.3+):

./script/plugin install http://mattmccray.com/svn/rails/plugins/theme_support


In the next couple of days I'll have a trac installation up and running for it too.


You can, of course, still get the theme_generator from RubyForge. But I think the plugin will be the approach I will recommend moving forward.


Try it out and let me know what you think!

Posted
19 Comments
Nov 14, 2005
protocool said...
svn link requires a password....
Nov 14, 2005
M@ said...
Ah, the repos isn't setup to be accessible anonymously yet...
You can download a zip of the plugin at the development site homepage.
Nov 15, 2005
Kevin said...
Great work! Already using it 'live' on here and here. One set of code and two themes - great, thanks!
Nov 26, 2005
Jon said...
I much prefer it *not* being a plugin. Less intrusive, more trustworthy that way....
Dec 09, 2005
JiaYun said...
The above problems have gone in Rails 0.14.4.
Jan 27, 2006
Kevin said...
regading the 'NoMethodError undefined method `current_theme'' error.
I'm also getting this with the pure plugin version if I try and send mail from the app. The gem version seems to work fine though.
I'm guessing that the pure plugin tries to patch actionview in a way that mailer does not like?!
Jan 30, 2006
David Morton said...
I'm working on a project that needs both theme support and translations. I know that the rails community is working on several approaches to translations, but I have another thought...
When it comes to caching, themes and translations need some interweaving so that various translations can be cached. It's almost like a translation is a sub-theme, or variation on a theme.
I'd like to help work on a method to provide translations built into the the theme framework... Contact me at: mortonda @ dgrmm.net if you are interested in this approach...
Feb 16, 2006
Yann Lugrin said...
Hi,
I have the same error with ActionMailer::Base.
NoMethodError: undefined method `current_theme' for #
----
MailContactRequest is a model :
class MailContactRequest
Feb 16, 2006
Yann Lugrin said...
Hi,
I have the same error with ActionMailer::Base.
NoMethodError: undefined method `current_theme' for #
MailContactRequest is a model :
class MailContactRequest
Feb 16, 2006
Yann Lugrin said...
Hi (sorry for other comment, probleme with special char),
I have the same error with ActionMailer::Base.
NoMethodError: undefined method `current_theme' for #
MailContactRequest is a model extend ActionMailer::Base.
MailContactRequest.create_new() send a mail, and use template to format this.
The error raise in actionview_ex.rb at line 16 (controller.current_theme), controller is a MailContactRequest object, and not a ActionController.
This error is resolved if extend ActionMailer::Base to support themes.
Mar 04, 2006
matt g said...
There seems to be a problem with using liquid templates if you have the newest version of liquid installed. There is no longer a register_block method. Any ideas on how to fix this?
Mar 07, 2006
David Morton said...
assert_existance_of_template_file in actionController needs to be updated to look for theme files. Otherwise if the original file is missing, it doesn't work. This limits themes to only using existing files...
Mar 14, 2006
Efrén said...
We noticed that your blog have some Ruby On Rails related content and that
is why we would like to invite you to register yourself and your
blog at RubyCorner, a directory of Ruby related blogs:
http://www.rubycorner.com/
We like to think about RubyCorner as a "meeting place" for the
community, also as a "focal point" where the people new to this
technology can quickly tune into the pulse of the community.
Registering your blog will help build a valuable resource for
this growing community.
Thanks.
Mar 21, 2006
Rodrigo said...
Hi, i have the same error with ActionMailer::Base.
How can i "extend ActionMailer::Base to support themes"? (I'm a newbie to RoR)
May 17, 2006
Rafael Lima said...
I had a problem with sub-dirs like /images/buttons/btn_enter.gif
So I changed :filename to *filename on lines 26, 27, 28 of routeset_ex.rb and put params[:filename] = File.join(params[:filename]) one line after "def stylesheets", "def javascript" and "def images".
I'm using Rails 1.1.2
May 25, 2006
Rajesh Shetty said...
Add empty current_theme and force_liquid_template in UserNotify class, that should fix it
Jun 09, 2006
Happy person said...
Thanks for this. *It just works*. Being a newbie, I was hacking apart typo. Cheers.
Jun 09, 2006
Happy person said...
Just a comment on some things I needed:
- restart the server to register the plugin
- ensure that the views/layouts/[default].rhtml exists so that it can be overriden
Jun 24, 2008
vendra said...
Tired of finding the file through enormous amount of searchers? 1 center- 1 enter. http://megaupload.name/

Leave a comment...

Theme by Cory Watilo.
More great Posterous themes at themes.posterous.com.