-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedge_template.rb
More file actions
73 lines (61 loc) · 2.29 KB
/
edge_template.rb
File metadata and controls
73 lines (61 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# This script is designed to be used with Ruby on Rails' new project generator:
#
# rails new my_app -m http://emberjs.com/template.rb
#
# For more information about the template API, please see the following Rails
# guide:
#
# http://edgeguides.rubyonrails.org/rails_application_templates.html
run "rm public/index.html"
# Install required gems
gem "active_model_serializers"
gem_group :assets do
gem "ember-rails"
end
run "bundle install"
# This needs to be done outside the bootstrap generator
# to avoid an initial "unknown variant" error.
environment <<-RUBY.strip_heredoc, :env => :development
config.ember.variant = :development
RUBY
environment <<-RUBY.strip_heredoc, :env => :test
config.ember.variant = :development
RUBY
environment <<-RUBY.strip_heredoc, :env => :production
config.ember.variant = :production
RUBY
# Configure the app to serve Ember.js and app assets from an AssetsController
generate "ember:bootstrap"
generate "ember:install", "--head"
generate :controller, "Assets", "index"
run "rm app/views/assets/index.html.erb"
file 'app/views/assets/index.html.erb', <<-CODE
<!DOCTYPE html>
<html>
<head>
<title>#{@app_name.titleize}</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= csrf_meta_tags %>
</head>
<body>
<%= javascript_include_tag "application" %>
</body>
</html>
CODE
remove_file 'app/assets/javascripts/templates/application.handlebars'
file 'app/assets/javascripts/templates/application.handlebars', <<-CODE
<div style="width: 600px; border: 6px solid #eee; margin: 0 auto; padding: 20px; text-align: center; font-family: sans-serif;">
<img src="http://emberjs.com/images/about/ember-productivity-sm.png" style="display: block; margin: 0 auto;">
<h1>Welcome to Ember.js!</h1>
<p>You're running an Ember.js app on top of Ruby on Rails. To get started, replace this content
(inside <code>app/assets/javascripts/templates/application.handlebars</code>) with your application's
HTML.</p>
</div>
CODE
run "rm -rf app/views/layouts"
route "root :to => 'assets#index'"
# Generate a default serializer that is compatible with ember-data
generate :serializer, "application", "--parent", "ActiveModel::Serializer"
inject_into_class "app/serializers/application_serializer.rb", 'ApplicationSerializer' do
" embed :ids, :include => true\n"
end