|
1 | 1 | # EmberCli::Deploy::Redis
|
2 | 2 |
|
3 |
| -[EmberCLI Rails] is an integration story between (surprise suprise) EmberCLI and |
4 |
| -Rails 3.1 and up. |
| 3 | +[EmberCLI Rails] is a tool to unify your EmberCLI and Rails Workflows. |
5 | 4 |
|
6 | 5 | [ember-cli-deploy] is a simple, flexible deployment for your Ember CLI app.
|
7 | 6 |
|
8 |
| -[ember-deploy-redis] is the redis-adapter implementation to use Redis with ember-deploy. |
| 7 | +[ember-cli-deploy-redis] is an `ember-cli-deploy` plugin to upload `index.html` |
| 8 | +to a Redis store. |
9 | 9 |
|
10 |
| -`ember-cli-rails-deploy-redis` wires up all three. |
| 10 | +`ember-cli-rails-deploy-redis` is a gem that integrates all three. |
11 | 11 |
|
12 |
| -[EmberCLI Rails]: https://github.com/rwz/ember-cli-rails |
13 |
| -[ember-cli-deploy]: https://github.com/ember-cli/ember-cli-deploy |
14 |
| -[ember-deploy-redis]: https://github.com/LevelbossMike/ember-deploy-redis |
| 12 | +This project streamlines the process of pushing and serving EmberCLI-built |
| 13 | +assets from Rails. |
15 | 14 |
|
16 |
| -## Installation |
| 15 | +[EmberCLI Rails]: https://github.com/thoughtbot/ember-cli-rails |
| 16 | +[ember-cli-deploy]: http://ember-cli.com/ember-cli-deploy/ |
| 17 | +[ember-cli-deploy-redis]: https://github.com/ember-cli-deploy/ember-cli-deploy-redis |
| 18 | + |
| 19 | +## Install |
17 | 20 |
|
18 | 21 | Add this line to your application's Gemfile:
|
19 | 22 |
|
20 | 23 | ```ruby
|
21 |
| -gem 'ember-cli-rails-deploy-redis' |
| 24 | +group :production do |
| 25 | + gem 'ember-cli-rails-deploy-redis' |
| 26 | +end |
22 | 27 | ```
|
23 | 28 |
|
24 | 29 | And then execute:
|
25 | 30 |
|
26 | 31 | ```bash
|
27 |
| -$ bundle |
| 32 | +$ bundle install |
28 | 33 | ```
|
29 | 34 |
|
30 |
| -## Usage |
31 |
| - |
32 |
| -The EmberCLI community recently unified the various deployment techniques into a |
33 |
| -single, core-team supported project: [ember-cli-deploy][ember-cli-deploy]. |
34 |
| - |
35 |
| -This project attempts to streamline the process of pushing and serving |
36 |
| -EmberCLI-built static assets. |
37 |
| - |
38 |
| -To integrate with `ember-cli-deploy`'s ["Lightning Fast Deploys"][lightning] |
39 |
| -(using the Redis adapter), instantiate an `EmberCli::Deploy::Redis` |
40 |
| -in your controller: |
41 |
| - |
42 |
| -```ruby |
43 |
| -require "ember_cli/deploy/redis" |
44 |
| - |
45 |
| -class ApplicationController < ActionController::Base |
46 |
| - def index |
47 |
| - @deploy = EmberCli::Deploy::Redis.new(namespace: "frontend") |
48 |
| - |
49 |
| - render text: @deploy.html, layout: false |
50 |
| - end |
51 |
| -end |
52 |
| -``` |
| 35 | +## Setup |
53 | 36 |
|
54 |
| -`EmberCli::Deploy::Redis` takes a `namespace` (the name of your app declared in |
55 |
| -your initializer) and handles all interaction with the Redis instance. |
| 37 | +First, [configure your application to integrate with |
| 38 | +`ember-cli-rails`][ember-cli-rails-setup]. |
56 | 39 |
|
57 |
| -This is great for `staging` and `production` deploys, but introduces an extra |
58 |
| -step in the feedback loop during development. |
| 40 | +Then, to integrate with `ember-cli-deploy`'s ["Lightning Fast Deploys"][lightning] |
| 41 | +(using the Redis adapter) in `production`, instantiate configure EmberCLI-Rails |
| 42 | +to deploy with the `EmberCli::Deploy::Redis` strategy: |
59 | 43 |
|
60 |
| -Luckily, `EmberCli::Deploy::Redis` also accepts an `index_html` override, which |
61 |
| -will replace the call to the Redis instance. This allows integration with the |
62 |
| -normal `ember-cli-rails` workflow: |
| 44 | +[ember-cli-rails-setup]: https://github.com/thoughtbot/ember-cli-rails#setup |
63 | 45 |
|
64 | 46 | ```ruby
|
65 |
| -require "ember_cli/deploy/redis" |
66 |
| - |
67 |
| -class ApplicationController < ActionController::Base |
68 |
| - def index |
69 |
| - @deploy = EmberCli::Deploy::Redis.new( |
70 |
| - namespace: "frontend", |
71 |
| - index_html: index_html, |
72 |
| - ) |
73 |
| - |
74 |
| - render text: @deploy.html, layout: false |
75 |
| - end |
76 |
| - |
77 |
| - private |
78 |
| - |
79 |
| - def index_html |
80 |
| - if serve_with_ember_cli_rails? |
81 |
| - render_to_string(:index) |
82 |
| - end |
83 |
| - end |
| 47 | +# config/initializers/ember.rb |
84 | 48 |
|
85 |
| - def serve_with_ember_cli_rails? |
86 |
| - ! %w[production staging].include?(Rails.env) |
87 |
| - end |
| 49 | +EmberCli.configure do |config| |
| 50 | + config.app :frontend, deploy: { production: EmberCli::Deploy::Redis } |
88 | 51 | end
|
89 | 52 | ```
|
90 | 53 |
|
91 |
| -Additionally, having access to the outbound HTML beforehand also enables |
92 |
| -controllers to inject additional markup, such as metadata, CSRF tokens, or |
93 |
| -analytics tags: |
| 54 | +Finally, set `ENV["REDIS_URL"]` to the URL |
| 55 | +[ember-cli-deploy-redis references][redis-config]. |
94 | 56 |
|
| 57 | +[redis-config]: https://github.com/ember-cli-deploy/ember-cli-deploy-redis#configuration-options |
95 | 58 |
|
96 |
| -```ruby |
97 |
| -require "ember_cli/deploy/redis" |
98 |
| - |
99 |
| -class ApplicationController < ActionController::Base |
100 |
| - def index |
101 |
| - @deploy = EmberCli::Deploy::Redis.new( |
102 |
| - namespace: "frontend", |
103 |
| - index_html: index_html, |
104 |
| - ) |
105 |
| - |
106 |
| - @deploy.append_to_head(render_to_string(partial: "my_csrf_and_metadata") |
107 |
| - @deploy.append_to_body(render_to_string(partial: "my_analytics") |
| 59 | +## Deploy |
108 | 60 |
|
109 |
| - render text: @deploy.html, layout: false |
110 |
| - end |
111 |
| - # ... |
112 |
| -end |
113 |
| -``` |
| 61 | +Deploy your application through [ember-cli-deploy-redis][deploy]. |
114 | 62 |
|
115 |
| -[ember-cli-deploy]: https://github.com/ember-cli/ember-cli-deploy |
116 |
| -[lightning]: https://github.com/ember-cli/ember-cli-deploy#lightning-approach-workflow |
| 63 | +[deploy]: https://github.com/ember-cli-deploy/ember-cli-deploy-redis#quick-start |
117 | 64 |
|
118 | 65 | ## Development
|
119 | 66 |
|
|
0 commit comments