public
Created — forked from chriseppstein/custom_functions.rb

  • Download Gist
runtime_stylesheets_controller.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
# Note: This might not work at all -- I didn't run it or anything.
class RuntimeStylesheetsController < ApplicationController
 
before_filter :lookup_user
caches_action :show, :cache_path => :show, :ttl => 24.hours
def show
contents = File.read("#{Rails.root}/app/runtime_stylesheets/#{params[:path].join("/")}")
Sass::Engine.new(contents, :custom => {:user => @user}).render
end
 
private
 
def lookup_user
@user = User.find_by_id(session[:user_id])
render :text => "", :status => :not_found unless @user
end
 
def show_url
"user_stylesheets/#{@user.id}/#{params[:path].join("/")}"
end
 
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.