railties 3.1.0.rc4 → 3.1.0.rc5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/CHANGELOG +7 -9
  2. data/bin/rails +2 -0
  3. data/guides/assets/images/rails_welcome.png +0 -0
  4. data/guides/rails_guides/generator.rb +1 -1
  5. data/guides/rails_guides/textile_extensions.rb +18 -17
  6. data/guides/source/3_0_release_notes.textile +21 -21
  7. data/guides/source/action_controller_overview.textile +1 -1
  8. data/guides/source/action_mailer_basics.textile +27 -6
  9. data/guides/source/action_view_overview.textile +6 -6
  10. data/guides/source/active_record_querying.textile +77 -7
  11. data/guides/source/active_record_validations_callbacks.textile +78 -81
  12. data/guides/source/active_support_core_extensions.textile +87 -31
  13. data/guides/source/ajax_on_rails.textile +1 -1
  14. data/guides/source/api_documentation_guidelines.textile +12 -8
  15. data/guides/source/asset_pipeline.textile +416 -0
  16. data/guides/source/association_basics.textile +2 -4
  17. data/guides/source/caching_with_rails.textile +7 -6
  18. data/guides/source/command_line.textile +78 -116
  19. data/guides/source/configuring.textile +34 -17
  20. data/guides/source/contribute.textile +1 -1
  21. data/guides/source/contributing_to_ruby_on_rails.textile +3 -3
  22. data/guides/source/debugging_rails_applications.textile +2 -2
  23. data/guides/source/form_helpers.textile +40 -51
  24. data/guides/source/getting_started.textile +641 -197
  25. data/guides/source/initialization.textile +4 -4
  26. data/guides/source/layouts_and_rendering.textile +2 -2
  27. data/guides/source/migrations.textile +114 -32
  28. data/guides/source/nested_model_forms.textile +6 -6
  29. data/guides/source/performance_testing.textile +6 -6
  30. data/guides/source/plugins.textile +23 -22
  31. data/guides/source/rails_application_templates.textile +8 -14
  32. data/guides/source/routing.textile +57 -51
  33. data/guides/source/ruby_on_rails_guides_guidelines.textile +3 -3
  34. data/guides/source/security.textile +10 -10
  35. data/guides/source/testing.textile +1 -1
  36. data/lib/rails.rb +27 -1
  37. data/lib/rails/all.rb +1 -0
  38. data/lib/rails/application.rb +4 -10
  39. data/lib/rails/application/configuration.rb +3 -12
  40. data/lib/rails/application/railties.rb +1 -1
  41. data/lib/rails/engine.rb +53 -42
  42. data/lib/rails/generators.rb +1 -1
  43. data/lib/rails/generators/app_base.rb +36 -15
  44. data/lib/rails/generators/generated_attribute.rb +1 -1
  45. data/lib/rails/generators/js/assets/assets_generator.rb +13 -0
  46. data/lib/rails/generators/js/assets/templates/javascript.js +2 -0
  47. data/lib/rails/generators/rails/app/app_generator.rb +3 -1
  48. data/lib/rails/generators/rails/app/templates/Gemfile +11 -7
  49. data/lib/rails/generators/rails/app/templates/config/application.rb +7 -3
  50. data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml +62 -0
  51. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +3 -3
  52. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +3 -12
  53. data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml +3 -3
  54. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +0 -3
  55. data/lib/rails/generators/rails/assets/assets_generator.rb +2 -9
  56. data/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +12 -10
  57. data/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec +5 -2
  58. data/lib/rails/generators/rails/plugin_new/templates/Gemfile +6 -3
  59. data/lib/rails/generators/rails/plugin_new/templates/Rakefile +5 -1
  60. data/lib/rails/generators/rails/plugin_new/templates/app/views/layouts/application.html.erb.tt +14 -0
  61. data/lib/rails/generators/rails/plugin_new/templates/rails/application.rb +5 -3
  62. data/lib/rails/info.rb +4 -0
  63. data/lib/rails/paths.rb +5 -5
  64. data/lib/rails/railtie.rb +4 -4
  65. data/lib/rails/tasks.rb +0 -1
  66. data/lib/rails/tasks/documentation.rake +3 -3
  67. data/lib/rails/tasks/engine.rake +2 -0
  68. data/lib/rails/tasks/framework.rake +3 -3
  69. data/lib/rails/tasks/tmp.rake +1 -1
  70. data/lib/rails/test_unit/testing.rake +2 -2
  71. data/lib/rails/version.rb +1 -1
  72. metadata +19 -33
  73. data/lib/rails/generators/rails/assets/templates/javascript.js.coffee +0 -3
  74. data/lib/rails/tasks/assets.rake +0 -21
@@ -30,13 +30,15 @@ module Rails
30
30
  @log_level = nil
31
31
  @middleware = app_middleware
32
32
  @generators = app_generators
33
+ @cache_store = [ :file_store, "#{root}/tmp/cache/" ]
33
34
 
34
35
  @assets = ActiveSupport::OrderedOptions.new
35
36
  @assets.enabled = false
36
37
  @assets.paths = []
37
- @assets.precompile = [ /\w+\.(?!js|css).+/, "application.js", "application.css" ]
38
+ @assets.precompile = [ /\w+\.(?!js|css).+/, /application.(css|js)$/ ]
38
39
  @assets.prefix = "/assets"
39
40
 
41
+ @assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/" ]
40
42
  @assets.js_compressor = nil
41
43
  @assets.css_compressor = nil
42
44
  end
@@ -70,7 +72,6 @@ module Rails
70
72
  paths.add "public/javascripts"
71
73
  paths.add "public/stylesheets"
72
74
  paths.add "tmp"
73
- paths.add "tmp/cache"
74
75
  paths
75
76
  end
76
77
  end
@@ -95,16 +96,6 @@ module Rails
95
96
  YAML::load(ERB.new(IO.read(paths["config/database"].first)).result)
96
97
  end
97
98
 
98
- def cache_store
99
- @cache_store ||= begin
100
- if File.exist?("#{root}/tmp/cache/")
101
- [ :file_store, "#{root}/tmp/cache/" ]
102
- else
103
- :memory_store
104
- end
105
- end
106
- end
107
-
108
99
  def log_level
109
100
  @log_level ||= Rails.env.production? ? :info : :debug
110
101
  end
@@ -4,7 +4,7 @@ module Rails
4
4
  class Application < Engine
5
5
  class Railties < Rails::Engine::Railties
6
6
  def all(&block)
7
- @all ||= railties + engines + super
7
+ @all ||= railties + engines + plugins
8
8
  @all.each(&block) if block
9
9
  @all
10
10
  end
@@ -5,13 +5,14 @@ require 'rbconfig'
5
5
  require 'rails/engine/railties'
6
6
 
7
7
  module Rails
8
- # Rails::Engine allows you to wrap a specific Rails application and share it across
9
- # different applications. Since Rails 3.0, every <tt>Rails::Application</tt> is nothing
10
- # more than an engine, allowing you to share it very easily.
8
+ # <tt>Rails::Engine</tt> allows you to wrap a specific Rails application or subset of
9
+ # functionality and share it with other applications. Since Rails 3.0, every
10
+ # <tt>Rails::Application</tt> is just an engine, which allows for simple
11
+ # feature and application sharing.
11
12
  #
12
- # Any <tt>Rails::Engine</tt> is also a <tt>Rails::Railtie</tt>, so the same methods
13
- # (like <tt>rake_tasks</tt> and +generators+) and configuration available in the
14
- # latter can also be used in the former.
13
+ # Any <tt>Rails::Engine</tt> is also a <tt>Rails::Railtie</tt>, so the same
14
+ # methods (like <tt>rake_tasks</tt> and +generators+) and configuration
15
+ # options that are available in railties can also be used in engines.
15
16
  #
16
17
  # == Creating an Engine
17
18
  #
@@ -71,12 +72,13 @@ module Rails
71
72
  #
72
73
  # == Paths
73
74
  #
74
- # Since Rails 3.0, both your application and engines do not have hardcoded paths.
75
- # This means that you are not required to place your controllers at <tt>app/controllers</tt>,
76
- # but in any place which you find convenient.
75
+ # Since Rails 3.0, applications and engines have more flexible path configuration (as
76
+ # opposed to the previous hardcoded path configuration). This means that you are not
77
+ # required to place your controllers at <tt>app/controllers</tt>, but in any place
78
+ # which you find convenient.
77
79
  #
78
80
  # For example, let's suppose you want to place your controllers in <tt>lib/controllers</tt>.
79
- # All you would need to do is:
81
+ # You can set that as an option:
80
82
  #
81
83
  # class MyEngine < Rails::Engine
82
84
  # paths["app/controllers"] = "lib/controllers"
@@ -105,9 +107,9 @@ module Rails
105
107
  # paths["config/routes"] # => ["config/routes.rb"]
106
108
  # end
107
109
  #
108
- # Your <tt>Application</tt> class adds a couple more paths to this set. And as in your
109
- # <tt>Application</tt>,all folders under +app+ are automatically added to the load path.
110
- # So if you have <tt>app/observers</tt>, it's added by default.
110
+ # The <tt>Application</tt> class adds a couple more paths to this set. And as in your
111
+ # <tt>Application</tt>, all folders under +app+ are automatically added to the load path.
112
+ # If you have an <tt>app/observers</tt> folder for example, it will be added by default.
111
113
  #
112
114
  # == Endpoint
113
115
  #
@@ -130,8 +132,8 @@ module Rails
130
132
  #
131
133
  # == Middleware stack
132
134
  #
133
- # As an engine can now be rack endpoint, it can also have a middleware stack. The usage is exactly
134
- # the same as in <tt>Application</tt>:
135
+ # As an engine can now be a rack endpoint, it can also have a middleware
136
+ # stack. The usage is exactly the same as in <tt>Application</tt>:
135
137
  #
136
138
  # module MyEngine
137
139
  # class Engine < Rails::Engine
@@ -141,8 +143,8 @@ module Rails
141
143
  #
142
144
  # == Routes
143
145
  #
144
- # If you don't specify an endpoint, routes will be used as the default endpoint. You can use them
145
- # just like you use an application's routes:
146
+ # If you don't specify an endpoint, routes will be used as the default
147
+ # endpoint. You can use them just like you use an application's routes:
146
148
  #
147
149
  # # ENGINE/config/routes.rb
148
150
  # MyEngine::Engine.routes.draw do
@@ -174,13 +176,14 @@ module Rails
174
176
  # == Engine name
175
177
  #
176
178
  # There are some places where an Engine's name is used:
179
+ #
177
180
  # * routes: when you mount an Engine with <tt>mount(MyEngine::Engine => '/my_engine')</tt>,
178
181
  # it's used as default :as option
179
182
  # * some of the rake tasks are based on engine name, e.g. <tt>my_engine:install:migrations</tt>,
180
183
  # <tt>my_engine:install:assets</tt>
181
184
  #
182
185
  # Engine name is set by default based on class name. For <tt>MyEngine::Engine</tt> it will be
183
- # <tt>my_engine_engine</tt>. You can change it manually it manually using the <tt>engine_name</tt> method:
186
+ # <tt>my_engine_engine</tt>. You can change it manually using the <tt>engine_name</tt> method:
184
187
  #
185
188
  # module MyEngine
186
189
  # class Engine < Rails::Engine
@@ -191,8 +194,8 @@ module Rails
191
194
  # == Isolated Engine
192
195
  #
193
196
  # Normally when you create controllers, helpers and models inside an engine, they are treated
194
- # as they were created inside the application. This means all application helpers and named routes
195
- # will be available to your engine's controllers.
197
+ # as if they were created inside the application itself. This means that all helpers and
198
+ # named routes from the application will be available to your engine's controllers as well.
196
199
  #
197
200
  # However, sometimes you want to isolate your engine from the application, especially if your engine
198
201
  # has its own router. To do that, you simply need to call +isolate_namespace+. This method requires
@@ -217,7 +220,7 @@ module Rails
217
220
  # If an engine is marked as isolated, +FooController+ has access only to helpers from +Engine+ and
218
221
  # <tt>url_helpers</tt> from <tt>MyEngine::Engine.routes</tt>.
219
222
  #
220
- # The next thing that changes in isolated engines is the behaviour of routes. Normally, when you namespace
223
+ # The next thing that changes in isolated engines is the behavior of routes. Normally, when you namespace
221
224
  # your controllers, you also need to do namespace all your routes. With an isolated engine,
222
225
  # the namespace is applied by default, so you can ignore it in routes:
223
226
  #
@@ -229,7 +232,7 @@ module Rails
229
232
  # need to use longer url helpers like <tt>my_engine_articles_path</tt>. Instead, you should simply use
230
233
  # <tt>articles_path</tt> as you would do with your application.
231
234
  #
232
- # To make that behaviour consistent with other parts of the framework, an isolated engine also has influence on
235
+ # To make that behavior consistent with other parts of the framework, an isolated engine also has influence on
233
236
  # <tt>ActiveModel::Naming</tt>. When you use a namespaced model, like <tt>MyEngine::Article</tt>, it will normally
234
237
  # use the prefix "my_engine". In an isolated engine, the prefix will be omitted in url helpers and
235
238
  # form fields for convenience.
@@ -240,9 +243,9 @@ module Rails
240
243
  # text_field :title # => <input type="text" name="article[title]" id="article_title" />
241
244
  # end
242
245
  #
243
- # Additionally an isolated engine will set its name according to namespace, so
246
+ # Additionally, an isolated engine will set its name according to namespace, so
244
247
  # MyEngine::Engine.engine_name will be "my_engine". It will also set MyEngine.table_name_prefix
245
- # to "my_engine_", changing MyEngine::Article model to use my_engine_article table.
248
+ # to "my_engine_", changing the MyEngine::Article model to use the my_engine_article table.
246
249
  #
247
250
  # == Using Engine's routes outside Engine
248
251
  #
@@ -274,12 +277,13 @@ module Rails
274
277
  # end
275
278
  # end
276
279
  #
277
- # Note that the <tt>:as</tt> option given to mount takes the <tt>engine_name</tT> as default, so most of the time
280
+ # Note that the <tt>:as</tt> option given to mount takes the <tt>engine_name</tt> as default, so most of the time
278
281
  # you can simply omit it.
279
282
  #
280
- # Finally, if you want to generate a url to an engine's route using <tt>polymorphic_url</tt>, you also need
281
- # to pass the engine helper. Let's say that you want to create a form pointing to one of the
282
- # engine's routes. All you need to do is pass the helper as the first element in array with
283
+ # Finally, if you want to generate a url to an engine's route using
284
+ # <tt>polymorphic_url</tt>, you also need to pass the engine helper. Let's
285
+ # say that you want to create a form pointing to one of the engine's routes.
286
+ # All you need to do is pass the helper as the first element in array with
283
287
  # attributes for url:
284
288
  #
285
289
  # form_for([my_engine, @user])
@@ -296,7 +300,7 @@ module Rails
296
300
  # helper MyEngine::SharedEngineHelper
297
301
  # end
298
302
  #
299
- # If you want to include all of the engine's helpers, you can use #helpers method on egine's
303
+ # If you want to include all of the engine's helpers, you can use #helpers method on an engine's
300
304
  # instance:
301
305
  #
302
306
  # class ApplicationController < ActionController::Base
@@ -305,7 +309,7 @@ module Rails
305
309
  #
306
310
  # It will include all of the helpers from engine's directory. Take into account that this does
307
311
  # not include helpers defined in controllers with helper_method or other similar solutions,
308
- # only helpers defined in helpers directory will be included.
312
+ # only helpers defined in the helpers directory will be included.
309
313
  #
310
314
  # == Migrations & seed data
311
315
  #
@@ -319,7 +323,7 @@ module Rails
319
323
  #
320
324
  # Note that some of the migrations may be skipped if a migration with the same name already exists
321
325
  # in application. In such a situation you must decide whether to leave that migration or rename the
322
- # migration in application and rerun copying migrations.
326
+ # migration in the application and rerun copying migrations.
323
327
  #
324
328
  # If your engine has migrations, you may also want to prepare data for the database in
325
329
  # the <tt>seeds.rb</tt> file. You can load that data using the <tt>load_seed</tt> method, e.g.
@@ -387,12 +391,25 @@ module Rails
387
391
  delegate :middleware, :root, :paths, :to => :config
388
392
  delegate :engine_name, :isolated?, :to => "self.class"
389
393
 
390
- def load_tasks(*)
394
+ def load_tasks(app=self)
395
+ railties.all { |r| r.load_tasks(app) }
391
396
  super
392
397
  paths["lib/tasks"].existent.sort.each { |ext| load(ext) }
393
398
  end
399
+
400
+ def load_generators(app=self)
401
+ railties.all { |r| r.load_generators(app) }
402
+ super
403
+ end
394
404
 
405
+ def load_console(app=self)
406
+ railties.all { |r| r.load_console(app) }
407
+ super
408
+ end
409
+
395
410
  def eager_load!
411
+ railties.all(&:eager_load!)
412
+
396
413
  config.eager_load_paths.each do |load_path|
397
414
  matcher = /\A#{Regexp.escape(load_path)}\/(.*)\.rb\Z/
398
415
  Dir.glob("#{load_path}/**/*.rb").sort.each do |file|
@@ -522,15 +539,9 @@ module Rails
522
539
  end
523
540
 
524
541
  initializer :append_assets_path do |app|
525
- if app.config.assets.respond_to?(:prepend_path)
526
- app.config.assets.prepend_path(*paths["vendor/assets"].existent)
527
- app.config.assets.prepend_path(*paths["lib/assets"].existent)
528
- app.config.assets.prepend_path(*paths["app/assets"].existent)
529
- else
530
- app.config.assets.paths.unshift(*paths["vendor/assets"].existent)
531
- app.config.assets.paths.unshift(*paths["lib/assets"].existent)
532
- app.config.assets.paths.unshift(*paths["app/assets"].existent)
533
- end
542
+ app.config.assets.paths.unshift(*paths["vendor/assets"].existent)
543
+ app.config.assets.paths.unshift(*paths["lib/assets"].existent)
544
+ app.config.assets.paths.unshift(*paths["app/assets"].existent)
534
545
  end
535
546
 
536
547
  initializer :prepend_helpers_path do |app|
@@ -572,7 +583,7 @@ module Rails
572
583
  end
573
584
 
574
585
  def has_migrations?
575
- paths["db/migrate"].first.present?
586
+ paths["db/migrate"].existent.any?
576
587
  end
577
588
 
578
589
  def find_root_with_flag(flag, default=nil)
@@ -51,7 +51,7 @@ module Rails
51
51
  :helper => true,
52
52
  :integration_tool => nil,
53
53
  :javascripts => true,
54
- :javascript_engine => nil,
54
+ :javascript_engine => :js,
55
55
  :orm => false,
56
56
  :performance_tool => nil,
57
57
  :resource_controller => :controller,
@@ -10,7 +10,7 @@ module Rails
10
10
  module Generators
11
11
  class AppBase < Base
12
12
  DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db )
13
- JDBC_DATABASES = %w( jdbcmysql jdbcsqlite3 jdbcpostgresql )
13
+ JDBC_DATABASES = %w( jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc )
14
14
  DATABASES.concat(JDBC_DATABASES)
15
15
 
16
16
  attr_accessor :rails_template
@@ -37,6 +37,9 @@ module Rails
37
37
  class_option :skip_active_record, :type => :boolean, :aliases => "-O", :default => false,
38
38
  :desc => "Skip Active Record files"
39
39
 
40
+ class_option :skip_sprockets, :type => :boolean, :aliases => "-S", :default => false,
41
+ :desc => "Skip Sprockets files"
42
+
40
43
  class_option :database, :type => :string, :aliases => "-d", :default => "sqlite3",
41
44
  :desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})"
42
45
 
@@ -64,8 +67,8 @@ module Rails
64
67
 
65
68
  def initialize(*args)
66
69
  @original_wd = Dir.pwd
67
-
68
70
  super
71
+ convert_database_option_for_jruby
69
72
  end
70
73
 
71
74
  protected
@@ -124,7 +127,7 @@ module Rails
124
127
  end
125
128
 
126
129
  def include_all_railties?
127
- !options[:skip_active_record] && !options[:skip_test_unit]
130
+ !options[:skip_active_record] && !options[:skip_test_unit] && !options[:skip_sprockets]
128
131
  end
129
132
 
130
133
  def comment_if(value)
@@ -157,14 +160,26 @@ module Rails
157
160
  when "postgresql" then "pg"
158
161
  when "frontbase" then "ruby-frontbase"
159
162
  when "mysql" then "mysql2"
160
- when "jdbcmysql" then "activerecord-jdbcmysql-adapter"
161
- when "jdbcsqlite3" then "activerecord-jdbcsqlite3-adapter"
162
- when "jdbcpostgresql" then "activerecord-jdbcpostgresql-adapter"
163
+ when "jdbcmysql" then "activerecord-jdbcmysql-adapter"
164
+ when "jdbcsqlite3" then "activerecord-jdbcsqlite3-adapter"
165
+ when "jdbcpostgresql" then "activerecord-jdbcpostgresql-adapter"
166
+ when "jdbc" then "activerecord-jdbc-adapter"
163
167
  else options[:database]
164
168
  end
165
169
  end
166
170
 
167
- def gem_for_ruby_debugger
171
+ def convert_database_option_for_jruby
172
+ if defined?(JRUBY_VERSION)
173
+ case options[:database]
174
+ when "oracle" then options[:database].replace "jdbc"
175
+ when "postgresql" then options[:database].replace "jdbcpostgresql"
176
+ when "mysql" then options[:database].replace "jdbcmysql"
177
+ when "sqlite3" then options[:database].replace "jdbcsqlite3"
178
+ end
179
+ end
180
+ end
181
+
182
+ def ruby_debugger_gemfile_entry
168
183
  if RUBY_VERSION < "1.9"
169
184
  "gem 'ruby-debug'"
170
185
  else
@@ -172,7 +187,7 @@ module Rails
172
187
  end
173
188
  end
174
189
 
175
- def gem_for_turn
190
+ def turn_gemfile_entry
176
191
  unless RUBY_VERSION < "1.9.2" || options[:skip_test_unit]
177
192
  <<-GEMFILE.strip_heredoc
178
193
  group :test do
@@ -183,18 +198,24 @@ module Rails
183
198
  end
184
199
  end
185
200
 
186
- def gem_for_javascript
201
+ def javascript_gemfile_entry
187
202
  "gem '#{options[:javascript]}-rails'" unless options[:skip_javascript]
188
203
  end
189
204
 
190
205
  def bundle_command(command)
191
- require 'bundler'
192
- require 'bundler/cli'
193
-
194
206
  say_status :run, "bundle #{command}"
195
- Bundler::CLI.new.send(command)
196
- rescue
197
- say_status :failure, "bundler raised an exception, are you offline?", :red
207
+
208
+ # We are going to shell out rather than invoking Bundler::CLI.new(command)
209
+ # because `rails new` loads the Thor gem and on the other hand bundler uses
210
+ # its own vendored Thor, which could be a different version. Running both
211
+ # things in the same process is a recipe for a night with paracetamol.
212
+ #
213
+ # We use backticks and #print here instead of vanilla #system because it
214
+ # is easier to silence stdout in the existing test suite this way. The
215
+ # end-user gets the bundler commands called anyway, so no big deal.
216
+ #
217
+ # Thanks to James Tucker for the Gem tricks involved in this call.
218
+ print `"#{Gem.ruby}" -rubygems "#{Gem.bin_path('bundler', 'bundle')}" #{command}`
198
219
  end
199
220
 
200
221
  def run_bundle
@@ -32,7 +32,7 @@ module Rails
32
32
  when :decimal then "9.99"
33
33
  when :datetime, :timestamp, :time then Time.now.to_s(:db)
34
34
  when :date then Date.today.to_s(:db)
35
- when :string then "MyString"
35
+ when :string then name == "type" ? "" : "MyString"
36
36
  when :text then "MyText"
37
37
  when :boolean then false
38
38
  when :references, :belongs_to then nil
@@ -0,0 +1,13 @@
1
+ require "rails/generators/named_base"
2
+
3
+ module Js
4
+ module Generators
5
+ class AssetsGenerator < Rails::Generators::NamedBase
6
+ source_root File.expand_path("../templates", __FILE__)
7
+
8
+ def copy_javascript
9
+ copy_file "javascript.js", File.join('app/assets/javascripts', class_path, "#{file_name}.js")
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -88,6 +88,7 @@ module Rails
88
88
  def lib
89
89
  empty_directory "lib"
90
90
  empty_directory_with_gitkeep "lib/tasks"
91
+ empty_directory_with_gitkeep "lib/assets"
91
92
  end
92
93
 
93
94
  def log
@@ -116,7 +117,8 @@ module Rails
116
117
  end
117
118
 
118
119
  def tmp
119
- empty_directory_with_gitkeep "tmp/cache"
120
+ empty_directory "tmp/cache"
121
+ empty_directory "tmp/cache/assets"
120
122
  end
121
123
 
122
124
  def vendor
@@ -5,13 +5,17 @@ source 'http://rubygems.org'
5
5
  <%= database_gemfile_entry -%>
6
6
 
7
7
  <%= "gem 'jruby-openssl'\n" if defined?(JRUBY_VERSION) -%>
8
- # Asset template engines
9
8
  <%= "gem 'json'\n" if RUBY_VERSION < "1.9.2" -%>
10
- gem 'sass-rails', "~> 3.1.0.rc"
11
- gem 'coffee-script'
12
- gem 'uglifier'
13
9
 
14
- <%= gem_for_javascript %>
10
+ # Gems used only for assets and not required
11
+ # in production environments by default.
12
+ group :assets do
13
+ gem 'sass-rails', "~> 3.1.0.rc"
14
+ gem 'coffee-rails', "~> 3.1.0.rc"
15
+ gem 'uglifier'
16
+ end
17
+
18
+ <%= javascript_gemfile_entry %>
15
19
 
16
20
  # Use unicorn as the web server
17
21
  # gem 'unicorn'
@@ -20,6 +24,6 @@ gem 'uglifier'
20
24
  # gem 'capistrano'
21
25
 
22
26
  # To use debugger
23
- # <%= gem_for_ruby_debugger %>
27
+ # <%= ruby_debugger_gemfile_entry %>
24
28
 
25
- <%= gem_for_turn -%>
29
+ <%= turn_gemfile_entry -%>