Currently, It's not possible to pass a revision as a query string param to the EmberController, in order to load a different index.html (based on the revision).
This can be a very helpful feature, in order to be able to assert that a version you've just deployed is working correctly in production, before actually releasing ('activating') it.
However, I couldn't figure out an elegant way of solving this without altering code in both ember-cli-rails-deploy-redis AND ember-cli-rails. Would love to hear your input:
From ember-cli-rails gem source, app/helpers/ember_rails_helper.rb:
module EmberRailsHelper
def render_ember_app(name, &block)
EmberCli[name].build
markup_capturer = HtmlPage::Capture.new(self, &block)
head, body = markup_capturer.capture
render inline: EmberCli[name].index_html(head: head, body: body)
end
end
render_ember_app is being called from the main ember view, which then calls EmberCli::App's instance index_html method, passing head and body params.
EmberCli::App#index_html method looks like this:
def index_html(head:, body:)
html = HtmlPage::Renderer.new(
head: head,
body: body,
content: deploy.index_html,
)
html.render
end
That means that the actual deploy instance (In this case, an instance of EmberCli::Deploy::Redis) cannot receive additional options (like revision from the request params) on index_html.
A relatively easy solution would be to pass the request context to App#index_html as part of EmberRailsHelper#render_ember_app which in turn will forward it to Deploy#index_html.
Then in ember-cli-rails-deploy-redisEmberCli::Deploy::Redis#index_html we can do something like this:
def index_html(request)
revision = request.params[:revision]
redis_client.get(deploy_key(revision: revision)).presence || index_html_missing!
end
Currently, It's not possible to pass a
revision
as a query string param to the EmberController, in order to load a differentindex.html
(based on the revision).This can be a very helpful feature, in order to be able to assert that a version you've just deployed is working correctly in production, before actually releasing ('activating') it.
However, I couldn't figure out an elegant way of solving this without altering code in both
ember-cli-rails-deploy-redis
ANDember-cli-rails
. Would love to hear your input:From
ember-cli-rails
gem source,app/helpers/ember_rails_helper.rb
:render_ember_app
is being called from the main ember view, which then callsEmberCli::App
's instanceindex_html
method, passinghead
andbody
params.EmberCli::App#index_html
method looks like this:That means that the actual
deploy
instance (In this case, an instance ofEmberCli::Deploy::Redis
) cannot receive additional options (likerevision
from the request params) onindex_html
.A relatively easy solution would be to pass the
request
context toApp#index_html
as part ofEmberRailsHelper#render_ember_app
which in turn will forward it toDeploy#index_html
.Then in
ember-cli-rails-deploy-redis
EmberCli::Deploy::Redis#index_html
we can do something like this:Would love to hear a better solution...