railties 3.1.0 → 3.1.1.rc1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,9 @@
1
- *Rails 3.1.0 (unreleased)*
1
+ *Rails 3.1.1 (unreleased)*
2
+
3
+ * No changes
4
+
5
+
6
+ *Rails 3.1.0 (August 30, 2011)*
2
7
 
3
8
  * The default database schema file is written as UTF-8. [Aaron Patterson]
4
9
 
@@ -170,7 +170,7 @@ class PostsController < ActionController::Base
170
170
  end
171
171
  </ruby>
172
172
 
173
- You can restrict it to some actions by using +:only+ or +:except+. Please read the docs at "<tt>ActionController::Streaming</tt>":http://edgeapi.rubyonrails.org/classes/ActionController/Streaming.html for more information.
173
+ You can restrict it to some actions by using +:only+ or +:except+. Please read the docs at "<tt>ActionController::Streaming</tt>":http://api.rubyonrails.org/classes/ActionController/Streaming.html for more information.
174
174
 
175
175
  * The redirect route method now also accepts a hash of options which will only change the parts of the url in question, or an object which responds to call, allowing for redirects to be reused.
176
176
 
@@ -346,6 +346,7 @@ has_many :things, :conditions => proc { "foo = #{bar}" } # after
346
346
  Inside the proc, +self+ is the object which is the owner of the association, unless you are eager loading the association, in which case +self+ is the class which the association is within.
347
347
 
348
348
  You can have any "normal" conditions inside the proc, so the following will work too:
349
+
349
350
  <ruby>
350
351
  has_many :things, :conditions => proc { ["foo = ?", bar] }
351
352
  </ruby>
@@ -353,6 +354,7 @@ has_many :things, :conditions => proc { ["foo = ?", bar] }
353
354
  * Previously +:insert_sql+ and +:delete_sql+ on +has_and_belongs_to_many+ association allowed you to call 'record' to get the record being inserted or deleted. This is now passed as an argument to the proc.
354
355
 
355
356
  * Added <tt>ActiveRecord::Base#has_secure_password</tt> (via <tt>ActiveModel::SecurePassword</tt>) to encapsulate dead-simple password usage with BCrypt encryption and salting.
357
+
356
358
  <ruby>
357
359
  # Schema: User(name:string, password_digest:string, password_salt:string)
358
360
  class User < ActiveRecord::Base
@@ -514,8 +514,8 @@ class UserMailerTest < ActionMailer::TestCase
514
514
  # Test the body of the sent email contains what we expect it to
515
515
  assert_equal [user.email], email.to
516
516
  assert_equal "Welcome to My Awesome Site", email.subject
517
- assert_match /<h1>Welcome to example.com, #{user.name}<\/h1>/, email.encoded
518
- assert_match /Welcome to example.com, #{user.name}/, email.encoded
517
+ assert_match(/<h1>Welcome to example.com, #{user.name}<\/h1>/, email.encoded)
518
+ assert_match(/Welcome to example.com, #{user.name}/, email.encoded)
519
519
  end
520
520
  end
521
521
  </ruby>
@@ -1016,7 +1016,7 @@ class A
1016
1016
  class_attribute :x, :instance_reader => false
1017
1017
  end
1018
1018
 
1019
- A.x = 1 # NoMethodError
1019
+ A.new.x = 1 # NoMethodError
1020
1020
  </ruby>
1021
1021
 
1022
1022
  For convenience +class_attribute+ also defines an instance predicate which is the double negation of what the instance reader returns. In the examples above it would be called +x?+.
@@ -13,13 +13,13 @@ endprologue.
13
13
 
14
14
  h3. What is the Asset Pipeline?
15
15
 
16
- The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages such as CoffeeScript, SCSS and ERB.
16
+ The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages such as CoffeeScript, Sass and ERB.
17
17
 
18
- Prior to Rails 3.1 these features were added through third-party Ruby libraries such as Jammit and Sprockets. Rails 3.1 includes the +sprockets-rails+ gem, which depends on the +sprockets+ gem, by default.
18
+ Prior to Rails 3.1 these features were added through third-party Ruby libraries such as Jammit and Sprockets. Rails 3.1 is integrated with Sprockets through Action Pack which depends on the +sprockets+ gem, by default.
19
19
 
20
20
  By having this as a core feature of Rails, all developers can benefit from the power of having their assets pre-processed, compressed and minified by one central library, Sprockets. This is part of Rails' "Fast by default" strategy as outlined by DHH in his 2011 keynote at Railsconf.
21
21
 
22
- In new Rails 3.1 application the asset pipeline is enabled by default. It can be disabled in +application.rb+ by putting this line inside the +Application+ class definition:
22
+ In Rails 3.1, the asset pipeline is enabled by default. It can be disabled in +application.rb+ by putting this line inside the +Application+ class definition:
23
23
 
24
24
  <plain>
25
25
  config.assets.enabled = false
@@ -36,7 +36,7 @@ The default behavior in Rails 3.1 and onward is to concatenate all files into on
36
36
 
37
37
  The second feature is to minify or compress assets. For CSS, this usually involves removing whitespace and comments. For JavaScript, more complex processes can be applied. You can choose from a set of built in options or specify your own.
38
38
 
39
- The third feature is the ability to code these assets using another language, or language extension. These include SCSS or Sass for CSS, CoffeeScript for JavaScript, and ERB for both.
39
+ The third feature is the ability to code these assets using another language, or language extension. These include Sass for CSS, CoffeeScript for JavaScript, and ERB for both.
40
40
 
41
41
  h4. What is Fingerprinting and Why Should I Care?
42
42
 
@@ -63,7 +63,7 @@ This has several disadvantages:
63
63
  <ol>
64
64
  <li>
65
65
  <strong>Not all caches will cache content with a query string</strong><br>
66
- "Steve Souders recommends":http://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/, "...avoiding a querystring for cacheable resources". He found that in these case 5-20% of requests will not be cached.
66
+ "Steve Souders recommends":http://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/, "...avoiding a querystring for cacheable resources". He found that in this case 5-20% of requests will not be cached.
67
67
  </li>
68
68
  <li>
69
69
  <strong>The file name can change between nodes in multi-server environments.</strong><br>
@@ -75,6 +75,8 @@ The other problem is that when static assets are deployed with each new release
75
75
 
76
76
  Fingerprinting avoids all these problems by ensuring filenames are consistent based on their content.
77
77
 
78
+ Fingerprinting is enabled by default for production and disabled for all the others environments. You can enable or disable it in your configuration through the +config.assets.digest+ option.
79
+
78
80
  More reading:
79
81
 
80
82
  * "Optimize caching":http://code.google.com/speed/page-speed/docs/caching.html
@@ -87,10 +89,14 @@ In previous versions of Rails, all assets were located in subdirectories of +pub
87
89
 
88
90
  This is not to say that assets can (or should) no longer be placed in +public+; they still can be and will be served as static files by the application or web server. You would only use +app/assets+ if you wish your files to undergo some pre-processing before they are served.
89
91
 
90
- When a scaffold or controller is generated for the application, Rails also generates a JavaScript file (or CoffeeScript file if the +coffee-script+ gem is in the +Gemfile+) and a Cascading Style Sheet file (or SCSS file if +sass-rails+ is in the +Gemfile+) for that controller.
92
+ In production, the default is to precompile these files to +public/assets+ so that they can be more efficiently delivered by the webserver.
93
+
94
+ When a scaffold or controller is generated for the application, Rails also generates a JavaScript file (or CoffeeScript file if the +coffee-rails+ gem is in the +Gemfile+) and a Cascading Style Sheet file (or SCSS file if +sass-rails+ is in the +Gemfile+) for that controller.
91
95
 
92
96
  For example, if a +ProjectsController+ is generated, there will be a new file at +app/assets/javascripts/projects.js.coffee+ and another at +app/assets/stylesheets/projects.css.scss+. You should put any JavaScript or CSS unique to a controller inside their respective asset files, as these files can then be loaded just for these controllers with lines such as +<%= javascript_include_tag params[:controller] %>+ or +<%= stylesheet_link_tag params[:controller] %>+.
93
97
 
98
+ NOTE: You will need a "ExecJS":https://github.com/sstephenson/execjs#readme supported runtime in order to use CoffeeScript. If you are using Mac OS X or Windows you have a JavaScript runtime installed in your operating system. Check "ExecJS":https://github.com/sstephenson/execjs#readme documentation to know all supported JavaScript runtimes.
99
+
94
100
  h4. Asset Organization
95
101
 
96
102
  Assets can be placed inside an application in one of three locations: +app/assets+, +lib/assets+ or +vendor/assets+.
@@ -101,13 +107,17 @@ Assets can be placed inside an application in one of three locations: +app/asset
101
107
 
102
108
  +vendor/assets+ is for assets that are owned by outside entities, such as code for JavaScript plugins.
103
109
 
104
- All subdirectories that exist within these three locations are added to the search path for Sprockets (visible by calling +Rails.application.config.assets.paths+ in a console). When an asset is requested, these paths are looked through to see if they contain an asset matching the name specified. Once an asset has been found, it's processed by Sprockets and served.
110
+ All subdirectories that exist within these three locations are added to the search path for Sprockets (visible by calling +Rails.application.config.assets.paths+ in a console). When an asset is requested, these paths are traversed to see if they contain an asset matching the name specified. Once an asset has been found, it's processed by Sprockets and served.
105
111
 
106
- h4. Coding Links to Assets
112
+ You can add additional (fully qualified) paths to the pipeline in +application.rb+. For example:
107
113
 
108
- To access assets, you use the same tags that you are generally familiar with:
114
+ <erb>
115
+ config.assets.paths << File.join(Rails.root, 'app', 'assets', 'flash')
116
+ </erb>
117
+
118
+ h4. Coding Links to Assets
109
119
 
110
- Sprockets does not add any new methods to require your assets, you still use the familiar +javascript_include_tag+ and +stylesheet_link_tag+.
120
+ Sprockets does not add any new methods to access your assets - you still use the familiar +javascript_include_tag+ and +stylesheet_link_tag+.
111
121
 
112
122
  <erb>
113
123
  <%= stylesheet_link_tag "application" %>
@@ -120,17 +130,27 @@ In regular views you can access images in the +assets/images+ directory like thi
120
130
  <%= image_tag "rails.png" %>
121
131
  </erb>
122
132
 
123
- Images can be organized into directories if required, and they can be accessed by specifying the directory's name in the tag:
133
+ Provided that the pipeline is enabled within your application (and not disabled in the current environment context), this file is served by Sprockets. If a file exists at +public/assets/rails.png+ it is served by the webserver.
134
+
135
+ Alternatively, a request for a file with an MD5 hash such as +public/assets/rails-af27b6a414e6da00003503148be9b409.png+ is treated the same way. How these hashes are generated is covered in the "In Production":#in-production section later on in this guide.
136
+
137
+ Sprockets will also look through the paths specified in +config.assets.paths+ which includes the standard application paths and any path added by Rails engines.
138
+
139
+ Images can also be organized into subdirectories if required, and they can be accessed by specifying the directory's name in the tag:
124
140
 
125
141
  <erb>
126
142
  <%= image_tag "icons/rails.png" %>
127
143
  </erb>
128
144
 
129
- Providing that assets are enabled within your application (+config.assets.enabled+ in the current environment's file is not set to +false+), this file is served by Sprockets unless a file at +public/assets/rails.png+ exists, in which case that file is served.
145
+ h5. CSS and ERB
130
146
 
131
- Alternatively, a file with an MD5 hash after its name such as +public/assets/rails-af27b6a414e6da00003503148be9b409.png+ is also picked up by Sprockets. How these hashes are generated is covered in the "Production Assets":#production_assets section later on in this guide.
147
+ If you add an +erb+ extension to a CSS asset, making it something such as +application.css.erb+, then you can use the +asset_path+ helper in your CSS rules:
132
148
 
133
- Otherwise, Sprockets looks through the available paths until it finds a file that matches the name and then serves it, first looking in the application's assets directories and then falling back to the various engines of the application.
149
+ <plain>
150
+ .class { background-image: url(<%= asset_path 'image.png' %>) }
151
+ </plain>
152
+
153
+ This writes the path to the particular asset being referenced. In this example, it would make sense to have an image in one of the asset load paths, such as +app/assets/images/image.png+, which would be referenced here. If this image is already available in +public/assets+ as a fingerprinted file, then that path is referenced.
134
154
 
135
155
  If you want to use a "css data URI":http://en.wikipedia.org/wiki/Data_URI_scheme -- a method of embedding the image data directly into the CSS file -- you can use the +asset_data_uri+ helper.
136
156
 
@@ -140,29 +160,37 @@ If you want to use a "css data URI":http://en.wikipedia.org/wiki/Data_URI_scheme
140
160
 
141
161
  This inserts a correctly-formatted data URI into the CSS source.
142
162
 
143
- h5. CSS and ERB
163
+ Note that the closing tag cannot be of the style +-%>+.
144
164
 
145
- If you add an +erb+ extension to a CSS asset, making it something such as +application.css.erb+, then you can use the +asset_path+ helper in your CSS rules:
165
+ h5. CSS and Sass
146
166
 
147
- <plain>
148
- .class { background-image: <%= asset_path 'image.png' %> }
149
- </plain>
167
+ When using the asset pipeline, paths to assets must be re-written and +sass-rails+ provides +_url+ and +_path+ helpers for the following asset classes: image, font, video, audio, JavaScript and stylesheet.
150
168
 
151
- This writes the path to the particular asset being referenced. In this example, it would make sense to have an image in one of the asset load paths, such as +app/assets/images/image.png+, which would be referenced here. If this image is already available in +public/assets+ as a fingerprinted file, then that path is referenced.
169
+ * +image_url("rails.png")+ becomes +url(/assets/rails.png)+.
170
+ * +image_path("rails.png")+ becomes +"/assets/rails.png"+.
152
171
 
153
- Note that the closing tag cannot be of the style +-%>+.
172
+ The more generic form can also be used but the asset path and class must both be specified:
154
173
 
155
- h5. CSS and SCSS
174
+ * +asset_url("rails.png", image)+ becomes +url(/assets/rails.png)+.
175
+ * +asset_path("rails.png", image)+ becomes +"/assets/rails.png"+.
156
176
 
157
- When using the asset pipeline, paths to assets must be re-written and +sass-rails+ provides +_url+ and +_path+ helpers for the following asset classes: image, font, video, audio, javascript, stylesheet.
177
+ h5. JavaScript/CoffeeScript and ERB
158
178
 
159
- * +image_url("rails.png")+ becomes +url(/assets/rails.png)+
160
- * +image_path("rails.png")+ becomes +"/assets/rails.png"+.
179
+ If you add an +erb+ extension to a JavaScript asset, making it something such as +application.js.erb+, then you can use the +asset_path+ helper in your JavaScript code:
161
180
 
162
- The more generic form can also be used but the asset path and class must both be specified:
181
+ <plain>
182
+ $('#logo').attr({
183
+ src: "<%= asset_path('logo.png') %>"
184
+ });
185
+ </plain>
163
186
 
164
- * +asset_url("rails.png", "image")+ becomes +url(/assets/rails.png)+
165
- * +asset_path("rails.png", "image")+ becomes +"/assets/rails.png"+
187
+ This writes the path to the particular asset being referenced.
188
+
189
+ Similarly, you can use the +asset_path+ helper in CoffeeScript files with +erb+ extension (eg. application.js.coffee.erb):
190
+
191
+ <plain>
192
+ $('#logo').attr src: "<% asset_path('logo.png') %>"
193
+ </plain>
166
194
 
167
195
  h4. Manifest Files and Directives
168
196
 
@@ -220,59 +248,89 @@ Keep in mind that the order of these pre-processors is important. For example, i
220
248
 
221
249
  h3. In Development
222
250
 
223
- In the development environment assets are compiled and cached on the first request after the server is started. Sprockets sets a +must-validate+ Cache-Control HTTP header to reduce request overhead on subsequent requests - on these the browser gets a 304 (not-modified) response.
224
-
225
- If any of the files in the manifest have changed between requests, the server responds with a new compiled file.
251
+ In development mode assets are served as separate files in the order they are specified in the manifest file.
226
252
 
227
- h4. Debugging Assets
228
-
229
- You can put +?debug_assets=true+ or +?debug_assets=1+ at the end of a URL or set +config.assets.debug+ and Sprockets expands the lines which load the assets. For example, if you had an +app/assets/javascripts/application.js+ file containing these lines:
253
+ This manifest +application.js+:
230
254
 
231
255
  <plain>
232
- //= require "projects"
233
- //= require "tickets"
256
+ //= require core
257
+ //= require projects
258
+ //= require tickets
234
259
  </plain>
235
260
 
236
- By default, this only renders this line when used with +<%= javascript_include_tag "application" %>+ in a view or layout:
261
+ would generate this HTML:
237
262
 
238
263
  <html>
239
- <script src='/assets/application.js'></script>
264
+ <script src='/assets/core.js?body=1'></script>
265
+ <script src='/assets/projects.js?body=1'></script>
266
+ <script src='/assets/tickets.js?body=1'></script>
240
267
  </html>
241
268
 
242
- When the +debug_assets+ parameter is set, this line is expanded out into three separate lines, separating out the combined file into their parts.
269
+ The +body+ param is required by Sprockets.
270
+
271
+ h4. Turning Debugging off
272
+
273
+ You can turn off debug mode by updating +development.rb+ to include:
274
+
275
+ <erb>
276
+ config.assets.debug = false
277
+ </erb>
278
+
279
+ When debug mode is off Sprockets will concatenate and run the necessary preprocessors on all files, generating the following HTML:
243
280
 
244
281
  <html>
245
282
  <script src='/assets/application.js'></script>
246
- <script src='/assets/projects.js'></script>
247
- <script src='/assets/tickets.js'></script>
248
283
  </html>
249
284
 
250
- This allows the individual parts of an asset to be rendered and debugged separately.
285
+ Assets are compiled and cached on the first request after the server is started. Sprockets sets a +must-revalidate+ Cache-Control HTTP header to reduce request overhead on subsequent requests -- on these the browser gets a 304 (not-modified) response.
286
+
287
+ If any of the files in the manifest have changed between requests, the server responds with a new compiled file.
288
+
289
+ You can put +?debug_assets=true+ or +?debug_assets=1+ at the end of a URL to enable debug mode on-demand, and this will render individual tags for each file. This is useful for tracking down exact line numbers when debugging.
290
+
291
+ Debug can also be set in the Rails helper methods:
292
+
293
+ <erb>
294
+ <%= stylesheet_link_tag "application", :debug => true %>
295
+ <%= javascript_include_tag "application", :debug => true %>
296
+ </erb>
297
+
298
+ The +:debug+ option is ignored if the debug mode is off.
299
+
300
+ You could potentially also enable compression in development mode as a sanity check, and disable it on-demand as required for debugging.
251
301
 
252
- NOTE. Assets debugging is turned on by default in development and test environments.
253
302
 
254
303
  h3. In Production
255
304
 
256
- In the production environment, assets are served slightly differently.
305
+ In the production environment Rails uses the fingerprinting scheme outlined above. By default it is assumed that assets have been precompiled and will be served as static assets by your web server.
257
306
 
258
- On the first request the assets are compiled and cached as described above, however the manifest names are altered to include an MD5 hash. Files names typically look like these:
307
+ During the precompilation phase an MD5 is generated from the contents of the compiled files, and inserted into the filenames as they are written to disc. These fingerprinted names are used by the Rails helpers in place of the manifest name.
259
308
 
260
- <plain>
261
- /assets/application-908e25f4bf641868d8683022a5b62f54.js
262
- /assets/application-4dd5b109ee3439da54f5bdfd78a80473.css
263
- </plain>
309
+ For example this:
264
310
 
265
- The MD5 is generated from the contents of the compiled files, and is included in the HTTP +Content-MD5+ header.
311
+ <erb>
312
+ <%= javascript_include_tag "application" %>
313
+ <%= stylesheet_link_tag "application" %>
314
+ </erb>
266
315
 
267
- Sprockets also sets the +Cache-Control+ HTTP header to +max-age=31536000+. This signals all caches between your server and the client browser that this content (the file served) can be cached for 1 year. The effect of this is to reduce the number of requests for this asset from your server; the asset has a good chance of being in the local browser cache or some intermediate cache.
316
+ generates something like this:
317
+
318
+ <html>
319
+ <script src="/assets/application-908e25f4bf641868d8683022a5b62f54.js" type="text/javascript"></script>
320
+ <link href="/assets/application-4dd5b109ee3439da54f5bdfd78a80473.css" media="screen" rel="stylesheet" type="text/css" />
321
+ </html>
268
322
 
269
- This behavior is controlled by the setting of +config.action_controller.perform_caching+ setting in Rails (which is +true+ for production, +false+ for everything else). This value is propagated to Sprockets during initialization for use when action_controller is not available.
323
+ The fingerprinting behavior is controlled by the setting of +config.assets.digest+ setting in Rails (which is +true+ for production, +false+ for everything else).
324
+
325
+ NOTE: Under normal circumstances the default option should not be changed. If there are no digests in the filenames, and far-future headers are set, remote clients will never know to refetch the files when their content changes.
270
326
 
271
327
  h4. Precompiling Assets
272
328
 
273
- Even though assets are served by Rack::Cache with far-future headers, in high traffic sites this may not be fast enough.
329
+ Rails comes bundled with a rake task to compile the asset manifests and other files in the pipeline to the disk.
330
+
331
+ Compiled assets are written to the location specified in +config.assets.prefix+. The default setting will use the +public/assets+ directory.
274
332
 
275
- Rails comes bundled with a rake task to compile the manifests to files on disc. These are located in the +public/assets+ directory where they are served by your web server instead of the Rails application.
333
+ You must use this task either during deployment or locally if you do not have write access to your production filesystem.
276
334
 
277
335
  The rake task is:
278
336
 
@@ -280,28 +338,53 @@ The rake task is:
280
338
  bundle exec rake assets:precompile
281
339
  </plain>
282
340
 
283
- Capistrano (v2.8.0+) has a recipe to handle this in deployment. Add the following line to +Capfile+:
341
+ Capistrano (v2.8.0 and above) has a recipe to handle this in deployment. Add the following line to +Capfile+:
284
342
 
285
343
  <erb>
286
344
  load 'deploy/assets'
287
345
  </erb>
288
346
 
289
- This links the folder specified in +config.assets.prefix+ to +shared/assets+. If you already use this folder you'll need to write your own deployment task.
347
+ This links the folder specified in +config.assets.prefix+ to +shared/assets+. If you already use this shared folder you'll need to write your own deployment task.
290
348
 
291
349
  It is important that this folder is shared between deployments so that remotely cached pages that reference the old compiled assets still work for the life of the cached page.
292
350
 
351
+ NOTE. If you are precompiling your assets locally, you can use +bundle install --without assets+ on the server to avoid installing the assets gems (the gems in the assets group in the Gemfile).
352
+
293
353
  The default matcher for compiling files includes +application.js+, +application.css+ and all files that do not end in +js+ or +css+:
294
354
 
295
355
  <ruby>
296
356
  [ /\w+\.(?!js|css).+/, /application.(css|js)$/ ]
297
357
  </ruby>
298
358
 
299
- If you have other manifests or individual stylesheets and JavaScript files to include, you can append them to the +precompile+ array:
359
+ If you have other manifests or individual stylesheets and JavaScript files to include, you can add them to the +precompile+ array:
300
360
 
301
361
  <erb>
302
362
  config.assets.precompile += ['admin.js', 'admin.css', 'swfObject.js']
303
363
  </erb>
304
364
 
365
+ The rake task also generates a +manifest.yml+ that contains a list with all your assets and their respective fingerprints. This is used by the Rails helper methods and avoids handing the mapping requests back to Sprockets. A typical manifest file looks like:
366
+
367
+ <plain>
368
+ ---
369
+ rails.png: rails-bd9ad5a560b5a3a7be0808c5cd76a798.png
370
+ jquery-ui.min.js: jquery-ui-7e33882a28fc84ad0e0e47e46cbf901c.min.js
371
+ jquery.min.js: jquery-8a50feed8d29566738ad005e19fe1c2d.min.js
372
+ application.js: application-3fdab497b8fb70d20cfc5495239dfc29.js
373
+ application.css: application-8af74128f904600e41a6e39241464e03.css
374
+ </plain>
375
+
376
+ The default location for the manifest is the root of the location specified in +config.assets.prefix+ ('/assets' by default).
377
+
378
+ This can be changed with the +config.assets.manifest+ option. A fully specified path is required:
379
+
380
+ <erb>
381
+ config.assets.manifest = '/path/to/some/other/location'
382
+ </erb>
383
+
384
+ NOTE: If there are missing precompiled files in production you will get an <tt>AssetNoPrecompiledError</tt> exception indicating the name of the missing file(s).
385
+
386
+ h5. Server Configuration
387
+
305
388
  Precompiled assets exist on the filesystem and are served directly by your webserver. They do not have far-future headers by default, so to get the benefit of fingerprinting you'll have to update your server configuration to add them.
306
389
 
307
390
  For Apache:
@@ -320,19 +403,83 @@ For Apache:
320
403
  </LocationMatch>
321
404
  </plain>
322
405
 
323
- TODO: NGINX instructions
406
+ For nginx:
407
+
408
+ <plain>
409
+ location ~ ^/assets/ {
410
+ expires 1y;
411
+ add_header Cache-Control public;
412
+
413
+ # Some browsers still send conditional-GET requests if there's a
414
+ # Last-Modified header or an ETag header even if they haven't
415
+ # reached the expiry date sent in the Expires header.
416
+ add_header Last-Modified "";
417
+ add_header ETag "";
418
+ break;
419
+ }
420
+ </plain>
324
421
 
325
- When files are precompiled, Sprockets also creates a "Gzip":http://en.wikipedia.org/wiki/Gzip (.gz) version of your assets. This avoids the server having to do this for any requests; it can simply read the compressed files from disc. You must configure your server to use gzip compression and serve the compressed assets that will be stored in the public/assets folder. The following configuration options can be used:
422
+ When files are precompiled, Sprockets also creates a "Gzip":http://en.wikipedia.org/wiki/Gzip (.gz) version of your assets. This avoids the server having to do this for any requests; it can simply read the compressed files from disk. You must configure your server to use gzip compression and serve the compressed assets that will be stored in the +public/assets+ folder. The following configuration options can be used:
326
423
 
327
- TODO: Apache instructions
424
+ For Apache:
328
425
 
426
+ <plain>
427
+ <LocationMatch "^/assets/.*$">
428
+ # 2 lines to serve pre-gzipped version
429
+ RewriteCond %{REQUEST_FILENAME}.gz -s
430
+ RewriteRule ^(.+) $1.gz [L]
431
+ </LocationMatch>
329
432
 
330
- h3. Customizing the Pipeline
433
+ # without these, Content-Type will be "application/x-gzip"
434
+ <FilesMatch "^/assets/.*\.css.gz$">
435
+ ForceType text/css
436
+ </FilesMatch>
437
+
438
+ <FilesMatch "^/assets/.*\.js.gz$">
439
+ ForceType text/javascript
440
+ </FilesMatch>
441
+ </plain>
442
+
443
+ For nginx:
444
+
445
+ <plain>
446
+ location ~ ^/(assets)/ {
447
+ root /path/to/public;
448
+ gzip_static on; # to serve pre-gzipped version
449
+ expires max;
450
+ add_header Cache-Control public;
451
+ }
452
+ </plain>
453
+
454
+ h4. Live Compilation
455
+
456
+ In some circumstances you may wish to use live compilation. In this mode all requests for assets in the pipeline are handled by Sprockets directly.
457
+
458
+ To enable this option set:
459
+
460
+ <erb>
461
+ config.assets.compile = true
462
+ </erb>
463
+
464
+ On the first request the assets are compiled and cached as outlined in development above, and the manifest names used in the helpers are altered to include the MD5 hash.
465
+
466
+ Sprockets also sets the +Cache-Control+ HTTP header to +max-age=31536000+. This signals all caches between your server and the client browser that this content (the file served) can be cached for 1 year. The effect of this is to reduce the number of requests for this asset from your server; the asset has a good chance of being in the local browser cache or some intermediate cache.
467
+
468
+ This mode uses more memory, performs poorer than the default and is not recommended.
469
+
470
+ When deploying a production application to a system without any pre-existing JavaScript runtimes, you may want to add one to your Gemfile:
331
471
 
472
+ <plain>
473
+ group :production do
474
+ gem 'therubyracer'
475
+ end
476
+ </plain>
477
+
478
+ h3. Customizing the Pipeline
332
479
 
333
480
  h4. CSS Compression
334
481
 
335
- There is currently one option for compressing CSS - YUI. This Gem extends the CSS syntax and offers minification.
482
+ There is currently one option for compressing CSS, YUI. This Gem extends the CSS syntax and offers minification.
336
483
 
337
484
  The following line enables YUI compression, and requires the +yui-compressor+ gem.
338
485
 
@@ -340,9 +487,9 @@ The following line enables YUI compression, and requires the +yui-compressor+ ge
340
487
  config.assets.css_compressor = :yui
341
488
  </erb>
342
489
 
343
- The +config.assets.compress+ must be set to +true+ to enable CSS compression
490
+ The +config.assets.compress+ must be set to +true+ to enable CSS compression.
344
491
 
345
- h4. JavaScript
492
+ h4. JavaScript Compression
346
493
 
347
494
  Possible options for JavaScript compression are +:closure+, +:uglifier+ and +:yui+. These require the use of the +closure-compiler+, +uglifier+ or +yui-compressor+ gems respectively.
348
495
 
@@ -356,6 +503,8 @@ config.assets.js_compressor = :uglifier
356
503
 
357
504
  The +config.assets.compress+ must be set to +true+ to enable JavaScript compression
358
505
 
506
+ NOTE: You will need a "ExecJS":https://github.com/sstephenson/execjs#readme supported runtime in order to use +uglifier+. If you are using Mac OS X or Windows you have installed a JavaScript runtime in your operating system. Check "ExecJS":https://github.com/sstephenson/execjs#readme documentation to know all supported JavaScript runtimes.
507
+
359
508
  h4. Using Your Own Compressor
360
509
 
361
510
  The compressor config settings for CSS and JavaScript also take any Object. This object must have a +compress+ method that takes a string as the sole argument and it must return a string.
@@ -402,7 +551,7 @@ WARNING: If you are upgrading an existing application and intend to use this opt
402
551
 
403
552
  h3. How Caching Works
404
553
 
405
- Sprockets uses the default rails cache store to cache assets in dev and production. The only difference is file names are fingerprinted and get far-future headers in production.
554
+ Sprockets uses the default Rails cache store to cache assets in development and production.
406
555
 
407
556
  TODO: Add more about changing the default store.
408
557
 
@@ -415,3 +564,69 @@ A good example of this is the +jquery-rails+ gem which comes with Rails as the s
415
564
  h3. Making Your Library or Gem a Pre-Processor
416
565
 
417
566
  TODO: Registering gems on "Tilt":https://github.com/rtomayko/tilt enabling Sprockets to find them.
567
+
568
+ h3. Upgrading from Old Versions of Rails
569
+
570
+ There are two issues when upgrading. The first is moving the files to the new locations. See the section above for guidance on the correct locations for different file types.
571
+
572
+ The second is updating the various environment files with the correct default options. The following changes reflect the defaults in version 3.1.0.
573
+
574
+ In +application.rb+:
575
+
576
+ <erb>
577
+ # Enable the asset pipeline
578
+ config.assets.enabled = true
579
+
580
+ # Version of your assets, change this if you want to expire all your assets
581
+ config.assets.version = '1.0'
582
+
583
+ # Change the path that assets are served from
584
+ # config.assets.prefix = "/assets"
585
+ </erb>
586
+
587
+ In +development.rb+:
588
+
589
+ <erb>
590
+ # Do not compress assets
591
+ config.assets.compress = false
592
+
593
+ # Expands the lines which load the assets
594
+ config.assets.debug = true
595
+ </erb>
596
+
597
+ And in +production.rb+:
598
+
599
+ <erb>
600
+ # Compress JavaScripts and CSS
601
+ config.assets.compress = true
602
+
603
+ # Choose the compressors to use
604
+ # config.assets.js_compressor = :uglifier
605
+ # config.assets.css_compressor = :yui
606
+
607
+ # Don't fallback to assets pipeline if a precompiled asset is missed
608
+ config.assets.compile = false
609
+
610
+ # Generate digests for assets URLs.
611
+ config.assets.digest = true
612
+
613
+ # Defaults to Rails.root.join("public/assets")
614
+ # config.assets.manifest = YOUR_PATH
615
+
616
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
617
+ # config.assets.precompile += %w( search.js )
618
+ </erb>
619
+
620
+ There are no changes to +test.rb+. The defaults in the test environment are: +config.assets.compile+ is true and +config.assets.compress+, +config.assets.debug+ and +config.assets.digest+ are false.
621
+
622
+ The following should also be added to +Gemfile+:
623
+
624
+ <plain>
625
+ # Gems used only for assets and not required
626
+ # in production environments by default.
627
+ group :assets do
628
+ gem 'sass-rails', "~> 3.1.0"
629
+ gem 'coffee-rails', "~> 3.1.0"
630
+ gem 'uglifier'
631
+ end
632
+ </plain>
@@ -124,7 +124,7 @@ Rails 3.1, by default, is set up to use the +sprockets+ gem to manage assets wit
124
124
 
125
125
  * +config.assets.compress+ a flag that enables the compression of compiled assets. It is explicitly set to true in +config/production.rb+.
126
126
 
127
- * +config.assets.css_compressor+ defines the CSS compressor to use. Only supported value at the moment is +:yui+, which uses the +yui-compressor+ gem.
127
+ * +config.assets.css_compressor+ defines the CSS compressor to use. It is set by default by +sass-rails+. The unique alternative value at the moment is +:yui+, which uses the +yui-compressor+ gem.
128
128
 
129
129
  * +config.assets.js_compressor+ defines the JavaScript compressor to use. Possible values are +:closure+, +:uglifier+ and +:yui+ which require the use of the +closure-compiler+, +uglifier+ or +yui-compressor+ gems respectively.
130
130
 
@@ -134,6 +134,18 @@ Rails 3.1, by default, is set up to use the +sprockets+ gem to manage assets wit
134
134
 
135
135
  * +config.assets.prefix+ defines the prefix where assets are served from. Defaults to +/assets+.
136
136
 
137
+ * +config.assets.digest+ enables the use of MD5 fingerprints in asset names. Set to +true+ by default in +production.rb+.
138
+
139
+ * +config.assets.debug+ disables the concatenation and compression of assets. Set to +false+ by default in +development.rb+.
140
+
141
+ * +config.assets.manifest+ defines the full path to be used for the asset precompiler's manifest file. Defaults to using +config.assets.prefix+.
142
+
143
+ * +config.assets.cache_store+ defines the cache store that Sprockets will use. The default is the Rails file store.
144
+
145
+ * +config.assets.version+ is an option string that is used in MD5 hash generation. This can be changed to force all files to be recompiled.
146
+
147
+ * +config.assets.compile+ is a boolean that can be used to turn on live Sprockets compilation in production.
148
+
137
149
 
138
150
  h4. Configuring Generators
139
151
 
@@ -258,16 +258,18 @@ h3. Contributing to the Rails Documentation
258
258
 
259
259
  Ruby on Rails has two main sets of documentation: The guides help you to learn Ruby on Rails, and the API is a reference.
260
260
 
261
- You can create an issue in GitHub issues to fix or expand documentation. However, if you're confident about your changes you can push them yourself directly via "docrails":https://github.com/lifo/docrails/tree/master. docrails is a branch with an *open commit policy* and public write access. Commits to docrails are still reviewed, but that happens after they are pushed. docrails is merged with master regularly, so you are effectively editing the Ruby on Rails documentation.
261
+ You can help improve the Rails guides by making them more coherent, adding missing information, correcting factual errors, fixing typos, bringing it up to date with the latest edge Rails. To get involved in the translation of Rails guides, please see "Translating Rails Guides":https://wiki.github.com/lifo/docrails/translating-rails-guides.
262
+
263
+ If you're confident about your changes, you can push them yourself directly via "docrails":https://github.com/lifo/docrails. docrails is a branch with an *open commit policy* and public write access. Commits to docrails are still reviewed, but that happens after they are pushed. docrails is merged with master regularly, so you are effectively editing the Ruby on Rails documentation.
264
+
265
+ If you are unsure of the documentation changes, you can create an issue in the "Rails":https://github.com/rails/rails/issues issues tracker on GitHub.
262
266
 
263
267
  When working with documentation, please take into account the "API Documentation Guidelines":api_documentation_guidelines.html and the "Ruby on Rails Guides Guidelines":ruby_on_rails_guides_guidelines.html.
264
268
 
265
- NOTE: As explained above, ordinary code patches should have proper documentation coverage. docrails is only used for isolated documentation improvements.
269
+ NOTE: As explained earlier, ordinary code patches should have proper documentation coverage. docrails is only used for isolated documentation improvements.
266
270
 
267
271
  WARNING: docrails has a very strict policy: no code can be touched whatsoever, no matter how trivial or small the change. Only RDoc and guides can be edited via docrails. Also, CHANGELOGs should never be edited in docrails.
268
272
 
269
- If you have an idea for a new guide you can refer to the "contribution page":contribute.html for instructions on getting involved.
270
-
271
273
  h3. Contributing to the Rails Code
272
274
 
273
275
  h4. Clone the Rails Repository
@@ -550,9 +550,9 @@ folders, and edit <tt>config/routes.rb</tt>. Here's a quick overview of what it
550
550
  |app/views/posts/new.html.erb |A view to create a new post|
551
551
  |app/views/posts/_form.html.erb |A partial to control the overall look and feel of the form used in edit and new views|
552
552
  |app/helpers/posts_helper.rb |Helper functions to be used from the post views|
553
- |app/assets/stylesheets/scaffold.css.scss |Cascading style sheet to make the scaffolded views look better|
554
- |app/assets/stylesheets/post.css.scss |Cascading style sheet for the posts controller|
555
- |app/assets/javascripts/post.js.coffee |CoffeeScript for the posts controller|
553
+ |app/assets/stylesheets/scaffolds.css.scss |Cascading style sheet to make the scaffolded views look better|
554
+ |app/assets/stylesheets/posts.css.scss |Cascading style sheet for the posts controller|
555
+ |app/assets/javascripts/posts.js.coffee |CoffeeScript for the posts controller|
556
556
  |test/unit/post_test.rb |Unit testing harness for the posts model|
557
557
  |test/functional/posts_controller_test.rb |Functional testing harness for the posts controller|
558
558
  |test/unit/helpers/posts_helper_test.rb |Unit testing harness for the posts helper|
@@ -822,8 +822,8 @@ this layout in your editor and modify the +body+ tag:
822
822
  <html>
823
823
  <head>
824
824
  <title>Blog</title>
825
- <%= stylesheet_link_tag :all %>
826
- <%= javascript_include_tag :defaults %>
825
+ <%= stylesheet_link_tag "application" %>
826
+ <%= javascript_include_tag "application" %>
827
827
  <%= csrf_meta_tags %>
828
828
  </head>
829
829
  <body style="background: #EEEEEE;">
@@ -1084,8 +1084,8 @@ def destroy
1084
1084
  @post.destroy
1085
1085
 
1086
1086
  respond_to do |format|
1087
- format.html { redirect_to(posts_url) }
1088
- format.json { render :json => {}, :status => :ok }
1087
+ format.html { redirect_to posts_url }
1088
+ format.json { head :ok }
1089
1089
  end
1090
1090
  end
1091
1091
  </ruby>
@@ -1454,7 +1454,7 @@ comment to a local variable named the same as the partial, in this case
1454
1454
 
1455
1455
  h4. Rendering a Partial Form
1456
1456
 
1457
- Lets also move that new comment section out to it's own partial, again, you
1457
+ Let's also move that new comment section out to its own partial. Again, you
1458
1458
  create a file +app/views/comments/_form.html.erb+ and in it you put:
1459
1459
 
1460
1460
  <erb>
@@ -1721,8 +1721,8 @@ This example shows another option of the render helper, being able to pass in
1721
1721
  local variables, in this case, we want the local variable +form+ in the partial
1722
1722
  to refer to the +post_form+ object.
1723
1723
 
1724
- We also add a <tt>@post.tags.build</tt> at the top of this form, this is to make
1725
- sure there is a new tag ready to have it's name filled in by the user. If you do
1724
+ We also add a <tt>@post.tags.build</tt> at the top of this form. This is to make
1725
+ sure there is a new tag ready to have its name filled in by the user. If you do
1726
1726
  not build the new tag, then the form will not appear as there is no new Tag
1727
1727
  object ready to create.
1728
1728
 
@@ -174,6 +174,10 @@ Ruby on Rails Guides
174
174
  <h3>Release Notes</h3>
175
175
 
176
176
  <dl>
177
+ <%= guide("Ruby on Rails 3.1 Release Notes", '3_1_release_notes.html') do %>
178
+ <p>Release notes for Rails 3.1.</p>
179
+ <% end %>
180
+
177
181
  <%= guide("Ruby on Rails 3.0 Release Notes", '3_0_release_notes.html') do %>
178
182
  <p>Release notes for Rails 3.0.</p>
179
183
  <% end %>
@@ -84,13 +84,14 @@
84
84
  <dd><a href="ruby_on_rails_guides_guidelines.html">Ruby on Rails Guides Guidelines</a></dd>
85
85
 
86
86
  <dt>Release Notes</dt>
87
+ <dd><a href="3_1_release_notes.html">Ruby on Rails 3.1 Release Notes</a></dd>
87
88
  <dd><a href="3_0_release_notes.html">Ruby on Rails 3.0 Release Notes</a></dd>
88
89
  <dd><a href="2_3_release_notes.html">Ruby on Rails 2.3 Release Notes</a></dd>
89
90
  <dd><a href="2_2_release_notes.html">Ruby on Rails 2.2 Release Notes</a></dd>
90
91
  </dl>
91
92
  </div>
92
93
  </li>
93
- <li><a href="contribute.html">Contribute</a></li>
94
+ <li><a href="contributing_to_ruby_on_rails.html">Contribute</a></li>
94
95
  <li><a href="credits.html">Credits</a></li>
95
96
  </ul>
96
97
  </div>
@@ -128,6 +129,10 @@
128
129
  <%= link_to 'Ruby on Rails Guides Guidelines', 'ruby_on_rails_guides_guidelines.html' %>
129
130
  for style and conventions.
130
131
  </p>
132
+ <p>
133
+ If for whatever reason you spot something to fix but cannot patch it yourself, please
134
+ <%= link_to 'open an issue', 'https://github.com/rails/rails/issues' %>.
135
+ </p>
131
136
  <p>And last but not least, any kind of discussion regarding Ruby on Rails
132
137
  documentation is very welcome in the <%= link_to 'rubyonrails-docs mailing list', 'http://groups.google.com/group/rubyonrails-docs' %>.
133
138
  </p>
@@ -207,7 +207,7 @@ config.middleware.clear
207
207
 
208
208
  <ruby>
209
209
  # config.ru
210
- use MyOwnStackFromStratch
210
+ use MyOwnStackFromScratch
211
211
  run ActionController::Dispatcher.new
212
212
  </ruby>
213
213
 
@@ -931,7 +931,7 @@ class UserControllerTest < ActionController::TestCase
931
931
 
932
932
  assert_equal "You have been invited by me@example.com", invite_email.subject
933
933
  assert_equal 'friend@example.com', invite_email.to[0]
934
- assert_match /Hi friend@example.com/, invite_email.body
934
+ assert_match(/Hi friend@example.com/, invite_email.body)
935
935
  end
936
936
  end
937
937
  </ruby>
data/lib/rails.rb CHANGED
@@ -22,8 +22,10 @@ require 'action_dispatch/railtie'
22
22
  if RUBY_VERSION < '1.9'
23
23
  $KCODE='u'
24
24
  else
25
- Encoding.default_external = Encoding::UTF_8
26
- Encoding.default_internal = Encoding::UTF_8
25
+ silence_warnings do
26
+ Encoding.default_external = Encoding::UTF_8
27
+ Encoding.default_internal = Encoding::UTF_8
28
+ end
27
29
  end
28
30
 
29
31
  module Rails
@@ -55,6 +55,11 @@ module Rails
55
55
 
56
56
  delegate :default_url_options, :default_url_options=, :to => :routes
57
57
 
58
+ def initialize
59
+ super
60
+ @initialized = false
61
+ end
62
+
58
63
  # This method is called just after an application inherits from Rails::Application,
59
64
  # allowing the developer to load classes in lib and use them during application
60
65
  # configuration.
@@ -28,7 +28,7 @@ module Rails
28
28
  logger.level = ActiveSupport::BufferedLogger.const_get(config.log_level.to_s.upcase)
29
29
  logger.auto_flushing = false if Rails.env.production?
30
30
  logger
31
- rescue StandardError => e
31
+ rescue StandardError
32
32
  logger = ActiveSupport::BufferedLogger.new(STDERR)
33
33
  logger.level = ActiveSupport::BufferedLogger::WARN
34
34
  logger.warn(
@@ -1,4 +1,5 @@
1
1
  require 'active_support/core_ext/string/encoding'
2
+ require 'active_support/core_ext/kernel/reporting'
2
3
  require 'rails/engine/configuration'
3
4
 
4
5
  module Rails
@@ -6,12 +7,13 @@ module Rails
6
7
  class Configuration < ::Rails::Engine::Configuration
7
8
  attr_accessor :allow_concurrency, :asset_host, :asset_path, :assets,
8
9
  :cache_classes, :cache_store, :consider_all_requests_local,
9
- :dependency_loading, :encoding, :filter_parameters,
10
+ :dependency_loading, :filter_parameters,
10
11
  :force_ssl, :helpers_paths, :logger, :preload_frameworks,
11
12
  :reload_plugins, :secret_token, :serve_static_assets,
12
13
  :static_cache_control, :session_options, :time_zone, :whiny_nils
13
14
 
14
15
  attr_writer :log_level
16
+ attr_reader :encoding
15
17
 
16
18
  def initialize(*)
17
19
  super
@@ -35,13 +37,14 @@ module Rails
35
37
  @assets = ActiveSupport::OrderedOptions.new
36
38
  @assets.enabled = false
37
39
  @assets.paths = []
38
- @assets.precompile = [ /\w+\.(?!js|css).+/, /application.(css|js)$/ ]
40
+ @assets.precompile = [ Proc.new{ |path| !File.extname(path).in?(['.js', '.css']) },
41
+ /application.(css|js)$/ ]
39
42
  @assets.prefix = "/assets"
40
43
  @assets.version = ''
41
44
  @assets.debug = false
42
45
  @assets.compile = true
43
46
  @assets.digest = false
44
- @assets.manifest = "#{root}/public#{@assets.prefix}"
47
+ @assets.manifest = nil
45
48
  @assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/" ]
46
49
  @assets.js_compressor = nil
47
50
  @assets.css_compressor = nil
@@ -54,8 +57,10 @@ module Rails
54
57
  def encoding=(value)
55
58
  @encoding = value
56
59
  if "ruby".encoding_aware?
57
- Encoding.default_external = value
58
- Encoding.default_internal = value
60
+ silence_warnings do
61
+ Encoding.default_external = value
62
+ Encoding.default_internal = value
63
+ end
59
64
  else
60
65
  $KCODE = value
61
66
  if $KCODE == "NONE"
data/lib/rails/engine.rb CHANGED
@@ -352,6 +352,7 @@ module Rails
352
352
  end
353
353
 
354
354
  def endpoint(endpoint = nil)
355
+ @endpoint ||= nil
355
356
  @endpoint = endpoint if endpoint
356
357
  @endpoint
357
358
  end
@@ -75,7 +75,7 @@ module Rails
75
75
  fallbacks.merge! config.fallbacks
76
76
  templates_path.concat config.templates
77
77
  templates_path.uniq!
78
- hide_namespaces *config.hidden_namespaces
78
+ hide_namespaces(*config.hidden_namespaces)
79
79
  end
80
80
 
81
81
  def self.templates_path
@@ -317,7 +317,7 @@ module Rails
317
317
  begin
318
318
  path = path.sub("#{base}/", "")
319
319
  require path
320
- rescue Exception => e
320
+ rescue Exception
321
321
  # No problem
322
322
  end
323
323
  end
@@ -118,8 +118,8 @@ module Rails
118
118
  if command.is_a?(Symbol)
119
119
  run "git #{command}"
120
120
  else
121
- command.each do |command, options|
122
- run "git #{command} #{options}"
121
+ command.each do |cmd, options|
122
+ run "git #{cmd} #{options}"
123
123
  end
124
124
  end
125
125
  end
@@ -9,7 +9,7 @@ require 'uri'
9
9
  module Rails
10
10
  module Generators
11
11
  class AppBase < Base
12
- DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db )
12
+ DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db sqlserver )
13
13
  JDBC_DATABASES = %w( jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc )
14
14
  DATABASES.concat(JDBC_DATABASES)
15
15
 
@@ -154,12 +154,13 @@ module Rails
154
154
  end
155
155
 
156
156
  def gem_for_database
157
- # %w( mysql oracle postgresql sqlite3 frontbase ibm_db jdbcmysql jdbcsqlite3 jdbcpostgresql )
157
+ # %w( mysql oracle postgresql sqlite3 frontbase ibm_db sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql )
158
158
  case options[:database]
159
159
  when "oracle" then "ruby-oci8"
160
160
  when "postgresql" then "pg"
161
161
  when "frontbase" then "ruby-frontbase"
162
162
  when "mysql" then "mysql2"
163
+ when "sqlserver" then "activerecord-sqlserver-adapter"
163
164
  when "jdbcmysql" then "activerecord-jdbcmysql-adapter"
164
165
  when "jdbcsqlite3" then "activerecord-jdbcsqlite3-adapter"
165
166
  when "jdbcpostgresql" then "activerecord-jdbcpostgresql-adapter"
@@ -209,7 +210,7 @@ module Rails
209
210
  group :assets do
210
211
  gem 'sass-rails', #{options.dev? || options.edge? ? " :git => 'git://github.com/rails/sass-rails.git', :branch => '3-1-stable'" : " ~> 3.1.0".inspect}
211
212
  gem 'coffee-rails', #{options.dev? || options.edge? ? ":git => 'git://github.com/rails/coffee-rails.git', :branch => '3-1-stable'" : "~> 3.1.0".inspect}
212
- gem 'uglifier'
213
+ gem 'uglifier', '>= 1.0.3'
213
214
  end
214
215
  GEMFILE
215
216
  end
@@ -10,6 +10,9 @@ source 'http://rubygems.org'
10
10
  <%= assets_gemfile_entry %>
11
11
  <%= javascript_gemfile_entry %>
12
12
 
13
+ # To use ActiveModel has_secure_password
14
+ # gem 'bcrypt-ruby', '~> 3.0.0'
15
+
13
16
  # Use unicorn as the web server
14
17
  # gem 'unicorn'
15
18
 
@@ -14,7 +14,7 @@ require "active_resource/railtie"
14
14
 
15
15
  if defined?(Bundler)
16
16
  # If you precompile assets before deploying to production, use this line
17
- Bundler.require *Rails.groups(:assets => %w(development test))
17
+ Bundler.require(*Rails.groups(:assets => %w(development test)))
18
18
  # If you want your assets lazily compiled in production, use this line
19
19
  # Bundler.require(:default, :assets, Rails.env)
20
20
  end
@@ -36,7 +36,4 @@
36
36
 
37
37
  # Print deprecation notices to the stderr
38
38
  config.active_support.deprecation = :stderr
39
-
40
- # Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
41
- config.assets.allow_debugging = true
42
39
  end
@@ -81,7 +81,7 @@ module Rails
81
81
  #
82
82
  # assert_file "app/controller/products_controller.rb" do |controller|
83
83
  # assert_instance_method :index, content do |index|
84
- # assert_match /Product\.all/, index
84
+ # assert_match(/Product\.all/, index)
85
85
  # end
86
86
  # end
87
87
  #
@@ -148,7 +148,7 @@ module Rails
148
148
  #
149
149
  # assert_migration "db/migrate/create_products.rb" do |migration|
150
150
  # assert_class_method :up, migration do |up|
151
- # assert_match /create_table/, up
151
+ # assert_match(/create_table/, up)
152
152
  # end
153
153
  # end
154
154
  #
@@ -161,7 +161,7 @@ module Rails
161
161
  #
162
162
  # assert_file "app/controller/products_controller.rb" do |controller|
163
163
  # assert_instance_method :index, content do |index|
164
- # assert_match /Product\.all/, index
164
+ # assert_match(/Product\.all/, index)
165
165
  # end
166
166
  # end
167
167
  #
@@ -1,4 +1,4 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/Fixtures.html
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
2
 
3
3
  <% unless attributes.empty? -%>
4
4
  one:
data/lib/rails/plugin.rb CHANGED
@@ -74,7 +74,8 @@ module Rails
74
74
  initializer :load_init_rb, :before => :load_config_initializers do |app|
75
75
  init_rb = File.expand_path("init.rb", root)
76
76
  if File.file?(init_rb)
77
- config = app.config
77
+ # This double assignment is to prevent an "unused variable" warning on Ruby 1.9.3.
78
+ config = config = app.config
78
79
  # TODO: think about evaling initrb in context of Engine (currently it's
79
80
  # always evaled in context of Rails::Application)
80
81
  eval(File.read(init_rb), binding, init_rb)
data/lib/rails/version.rb CHANGED
@@ -2,8 +2,8 @@ module Rails
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 1
5
- TINY = 0
6
- PRE = nil
5
+ TINY = 1
6
+ PRE = "rc1"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
9
9
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railties
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
5
- prerelease:
4
+ hash: 977940594
5
+ prerelease: true
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
- - 0
10
- version: 3.1.0
9
+ - 1
10
+ - rc1
11
+ version: 3.1.1.rc1
11
12
  platform: ruby
12
13
  authors:
13
14
  - David Heinemeier Hansson
@@ -15,7 +16,8 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-08-31 00:00:00 Z
19
+ date: 2011-09-14 00:00:00 -07:00
20
+ default_executable:
19
21
  dependencies:
20
22
  - !ruby/object:Gem::Dependency
21
23
  name: rake
@@ -88,12 +90,13 @@ dependencies:
88
90
  requirements:
89
91
  - - "="
90
92
  - !ruby/object:Gem::Version
91
- hash: 3
93
+ hash: 977940594
92
94
  segments:
93
95
  - 3
94
96
  - 1
95
- - 0
96
- version: 3.1.0
97
+ - 1
98
+ - rc1
99
+ version: 3.1.1.rc1
97
100
  type: :runtime
98
101
  version_requirements: *id005
99
102
  - !ruby/object:Gem::Dependency
@@ -104,18 +107,19 @@ dependencies:
104
107
  requirements:
105
108
  - - "="
106
109
  - !ruby/object:Gem::Version
107
- hash: 3
110
+ hash: 977940594
108
111
  segments:
109
112
  - 3
110
113
  - 1
111
- - 0
112
- version: 3.1.0
114
+ - 1
115
+ - rc1
116
+ version: 3.1.1.rc1
113
117
  type: :runtime
114
118
  version_requirements: *id006
115
119
  description: "Rails internals: application bootup, plugins, generators, and rake tasks."
116
120
  email: david@loudthinking.com
117
- executables:
118
- - rails
121
+ executables: []
122
+
119
123
  extensions: []
120
124
 
121
125
  extra_rdoc_files: []
@@ -123,7 +127,6 @@ extra_rdoc_files: []
123
127
  files:
124
128
  - CHANGELOG
125
129
  - README.rdoc
126
- - bin/rails
127
130
  - guides/assets/images/belongs_to.png
128
131
  - guides/assets/images/book_icon.gif
129
132
  - guides/assets/images/bullet.gif
@@ -269,7 +272,6 @@ files:
269
272
  - guides/source/caching_with_rails.textile
270
273
  - guides/source/command_line.textile
271
274
  - guides/source/configuring.textile
272
- - guides/source/contribute.textile
273
275
  - guides/source/contributing_to_ruby_on_rails.textile
274
276
  - guides/source/credits.html.erb
275
277
  - guides/source/debugging_rails_applications.textile
@@ -527,6 +529,7 @@ files:
527
529
  - lib/rails/generators/rails/generator/templates/templates/.empty_directory
528
530
  - lib/rails/generators/rails/plugin_new/templates/app/mailers/.empty_directory
529
531
  - lib/rails/generators/rails/plugin_new/templates/app/models/.empty_directory
532
+ has_rdoc: true
530
533
  homepage: http://www.rubyonrails.org
531
534
  licenses: []
532
535
 
@@ -550,16 +553,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
550
553
  required_rubygems_version: !ruby/object:Gem::Requirement
551
554
  none: false
552
555
  requirements:
553
- - - ">="
556
+ - - ">"
554
557
  - !ruby/object:Gem::Version
555
- hash: 3
558
+ hash: 25
556
559
  segments:
557
- - 0
558
- version: "0"
560
+ - 1
561
+ - 3
562
+ - 1
563
+ version: 1.3.1
559
564
  requirements: []
560
565
 
561
566
  rubyforge_project:
562
- rubygems_version: 1.8.8
567
+ rubygems_version: 1.3.7
563
568
  signing_key:
564
569
  specification_version: 3
565
570
  summary: Tools for creating, working with, and running Rails applications.
data/bin/rails DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require "rails/cli"
@@ -1,70 +0,0 @@
1
- h2. Contribute to the Rails Guides
2
-
3
- Rails Guides aim to improve the Rails documentation and to make the barrier to entry as low as possible. A reasonably experienced developer should be able to use the guides to come up to speed on Rails quickly. Our sponsors have contributed prizes for those who write an entire guide, but there are many other ways to contribute.
4
-
5
- endprologue.
6
-
7
- h3. How to Contribute?
8
-
9
- * We have an open commit policy: anyone is welcome to contribute and to review contributions.
10
- * "docrails is hosted on GitHub":https://github.com/lifo/docrails and has public write access.
11
- * Guides are written in Textile, and reside at +railties/guides/source+ in the docrails project.
12
- * Follow the "Rails Guides Conventions":https://wiki.github.com/lifo/docrails/rails-guides-conventions.
13
- * Assets are stored in the +railties/guides/assets+ directory.
14
- * Sample format : "Active Record Associations":https://github.com/lifo/docrails/blob/3e56a3832415476fdd1cb963980d0ae390ac1ed3/railties/guides/source/association_basics.textile.
15
- * Sample output : "Active Record Associations":association_basics.html.
16
- * You can build the Guides during testing by running +bundle exec rake generate_guides+ in the +railties+ directory.
17
- * You're encouraged to validate XHTML for the generated guides before committing your changes by running +bundle exec rake validate_guides+ in the +railties+ directory.
18
- * Edge guides "can be consulted online":http://edgeguides.rubyonrails.org/. That website is generated periodically from docrails.
19
-
20
- h3. What to Contribute?
21
-
22
- * We need authors, editors, proofreaders, and translators. Adding a single paragraph of quality content to a guide is a good way to get started.
23
- * The easiest way to start is by improving an existing guide:
24
- ** Improve the structure to make it more coherent.
25
- ** Add missing information.
26
- ** Correct any factual errors.
27
- ** Fix typos or improve style.
28
- ** Bring it up to date with the latest Edge Rails.
29
- * We're also open to suggestions for entire new guides:
30
- ** Contact lifo or fxn to get your idea approved. See the Contact section below.
31
- ** If you're the main author on a significant guide, you're eligible for the prizes.
32
-
33
- h3. How is the process?
34
-
35
- * The preferred way to contribute is to commit to docrails directly.
36
- * A new guide is only edited by its author until finished though.
37
- * If you are writing a new guide freely commit to docrails partial work and ping lifo or fxn when done with a first draft.
38
- * Guides reviewers will then provide feedback, some of it possibly in form of direct commits to agilize the process.
39
- * Eventually the guide will be approved and added to the index.
40
-
41
- h3. Prizes
42
-
43
- For each completed guide, the lead contributor will receive all of the following prizes:
44
-
45
- * $200 from Caboose Rails Documentation Project.
46
- * 1 year of GitHub Micro account worth $84.
47
- * 1 year of RPM Basic (Production performance management) for up to 10 hosts worth 12 months x $40 per host x 10 hosts = $4800. And also, savings of $45 per host per month over list price to upgrade to advanced product.
48
-
49
- h3. Rules
50
-
51
- * Guides are licensed under a Creative Commons Attribution-Share Alike 3.0 License.
52
- * If you're not sure whether a guide is actively being worked on, stop by IRC and ask.
53
- * If the same guide writer wants to write multiple guides, that's ideally the situation we'd love to be in! However, that guide writer will only receive the cash prize for all the subsequent guides (and not the GitHub or RPM prizes).
54
- * Our review team will have the final say on whether the guide is complete and of good enough quality.
55
-
56
- All authors should read and follow the "Rails Guides Conventions":ruby_on_rails_guides_guidelines.html and the "Rails API Documentation Conventions":api_documentation_guidelines.html.
57
-
58
- h3. Translations
59
-
60
- The translation effort for the Rails Guides is just getting underway. We know about projects to translate the Guides into Spanish, Portuguese, Polish, and French. For more details or to get involved see the "Translating Rails Guides":https://wiki.github.com/lifo/docrails/translating-rails-guides page.
61
-
62
- h3. Mailing List
63
-
64
- "Ruby on Rails: Documentation":http://groups.google.com/group/rubyonrails-docs is the mailing list for all the guides/documentation related discussions.
65
-
66
- h3. Contact
67
-
68
- * IRC : #docrails channel in irc.freenode.net
69
- * Twitter: "@docrails":http://twitter.com/docrails, "@lifo":http://twitter.com/lifo, "@fxn":http://twitter.com/fxn
70
- * Email : pratiknaik aT gmail, fxn aT hashref dot com