Installing the Theme support plugin with Rails 1.2
As usual, install from the subversion repository:
./script/plugin install http://mattmccray.com/svn/rails/plugins/theme_support
Then update the file which overrides your application's routes. It should be in /vendor/plugins/theme_support/lib/patches/routeset_ex.rb, replace its content with:
# Extends ActionController::Routing::RouteSet to automatically add the theme routes
class ActionController::Routing::RouteSet
alias_method :__draw, :draw
# Overrides the default RouteSet#draw to automatically
# include the routes needed by the ThemeController
def draw
clear!
map = Mapper.new(self)
create_theme_routes(map)
yield map
named_routes.install
end
# Creates the required routes for the ThemeController...
def create_theme_routes(map)
map.theme_images "/themes/:theme/images/*filename", :controller => 'theme', :action => 'images'
map.theme_stylesheets "/themes/:theme/stylesheets/*filename", :controller => 'theme', :action => 'stylesheets'
map.theme_javascript "/themes/:theme/javascript/*filename", :controller => 'theme', :action => 'javascript'
map.connect "/themes/*whatever", :controller => 'theme', :action => 'error'
end
end
Then generate a theme using:
./script/generate theme my_theme
You should at that point be able to get for example the following URL: http://localhost:3000/themes/my_theme/images/preview.png Your logs should say that the images action of the themes controller has been used to send the image file.
If that's the case, your installation is successful ! If it is not the case, do not hesitate to leave a comment here and we'll try to see what is the problem.
Comments
-
I applied the fix, but still get the error “MissingTemplate”. The trace says, that rails is still looking for the old templates ^^ any suggestions would be appreciated :-)
and here goes the complete trace:
ActionController::MissingTemplate (Missing layout $mylocalpath :-)$/app/views/layouts/default.rhtml): C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_co ntroller/base.rb:1211:in `assert_existence_of_template_file’ C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_co ntroller/layout.rb:238:in `render_without_benchmark’ C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_co ntroller/benchmarking.rb:50:in `render’ C:/Program Files/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure’ C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_co ntroller/benchmarking.rb:50:in `render’ $mylocalpath :-)$/app/controllers/blog_controlle r.rb:11:in `index’ C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_co ntroller/base.rb:1101:in `send’ C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_co ntroller/base.rb:1101:in `perform_action_without_filters’ C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_co ntroller/filters.rb:696:in `call_filters’ C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_co ntroller/filters.rb:722:in `run_before_filters’ $mylocalpath :-)$/app/controllers/application.rb :121:in `you_dont_have_bloody_clue’ C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_co ntroller/filters.rb:469:in `send’ C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_co ntroller/filters.rb:469:in `call’ C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_co ntroller/filters.rb:719:in `run_before_filters’ C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_co ntroller/filters.rb:694:in `call_filters’ C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_co ntroller/filters.rb:688:in `perform_action_without_benchmark’ C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_co ntroller/benchmarking.rb:66:in `perform_action_without_rescue’ C:/Program Files/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure’ C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_co ntroller/benchmarking.rb:66:in `perform_action_without_rescue’ C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_co ntroller/rescue.rb:83:in `perform_action’ C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_co ntroller/base.rb:435:in `send’ C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_co ntroller/base.rb:435:in `process_without_filters’ -
ok i was unable to make it work, so i wrote a few lines of code myself to serve the basic functionality.
-
I've cut your log a little :)
Are you sure the theme is correctly set in your application controller? And you have a layout in /theme/your_theme/views/layouts/default.rhtml
I've got that in my application controller:
theme :get_theme def get_theme if logged_in? session[:theme] ||= current_user.theme else session[:theme] = nil end endPS: I'll make sur to enable html for comments for next articles, textile is not working greatly on mephisto (bc. not correctly supported)...
-
ok thanks!
yes i have the same in my app controller (the layout is also set to default and everything is in the right place) – rails is just looking in the old path for whatever reason.
probably it’s the best way to wait for the next release of theme_support (especially looking forward to rails 2.0 ;-))