Skip to content

Instantly share code, notes, and snippets.

@ivanvanderbyl
Created March 2, 2016 19:05
Show Gist options
  • Save ivanvanderbyl/74d8f5238bc6b9847c30 to your computer and use it in GitHub Desktop.
Save ivanvanderbyl/74d8f5238bc6b9847c30 to your computer and use it in GitHub Desktop.
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