To use app/views/stylesheets/mystyle.rcss as an ERB template, follow these steps:
script/generate stylesheets

In config/routes.rb

map.connect 'stylesheets/:rcss', :controller => 'stylesheets', :action => 'rcss'

in app/helpers/application_helper.rb

module ApplicationHelper def rcss_path(name) file_base = name.gsub(/\.css$/i, '') return "#{RAILS_ROOT}/app/views/stylesheets/#{file_base}.rcss" end def stylesheet_tag(name) date = File.mtime(rcss_path(name)).to_i return "<link type=\"text/css\" rel=\"stylesheet\" href=\"/stylesheets/#{name}.css?#{date}\" />" end end

In app/controllers/stylesheets_controller.rb

class StylesheetsController < ApplicationController include ApplicationHelper layout nil session :off def rcss if name = params[:id] file_path = rcss_path(name) expires_in 3.days render(:file => file_path, :content_type => "text/css") else render(:nothing => true, :status => 404) end end end

in app/views/stylesheets/mystyle.rcss

html,body{
margin:0;
padding:0;
color: <%=@color%> /*example dynamic style*/
}
Then in your .rhtml template: <%= stylesheet_tag "mystyle" %>