Skip to content

Instantly share code, notes, and snippets.

@ravidsrk
Forked from chriseppstein/custom_functions.rb
Created February 23, 2012 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ravidsrk/1893608 to your computer and use it in GitHub Desktop.
Save ravidsrk/1893608 to your computer and use it in GitHub Desktop.
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment