Created
March 2, 2016 19:05
-
-
Save ivanvanderbyl/74d8f5238bc6b9847c30 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EmberController < ApplicationController | |
def app | |
content = bootstrap_index(params[:revision]) | |
render html: content.html_safe | |
end | |
private | |
def project_name | |
'dashboard' | |
end | |
def bootstrap_index(index_key = nil) | |
index_key &&= "#{project_name}:index:#{index_key}" | |
index_key ? load_index(index_key) : bootstrap_current | |
end | |
def bootstrap_current | |
index_key = redis.get("#{project_name}:index:current") | |
index_key = "#{project_name}:index:#{index_key}" | |
load_index(index_key) | |
end | |
def load_index(index_key) | |
redis.get(index_key) || | |
raise("No Ember app deployed at key '#{index_key}'") | |
end | |
def redis | |
@_redis ||= begin | |
redis_url = { url: "#{ENV['REDIS_URL']}" } | |
Redis.new(redis_url) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment