railties 3.1.0.rc1 → 3.1.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/CHANGELOG +2 -0
  2. data/guides/assets/images/radar.png +0 -0
  3. data/guides/assets/images/vijaydev.jpg +0 -0
  4. data/guides/rails_guides/helpers.rb +1 -1
  5. data/guides/source/action_view_overview.textile +6 -103
  6. data/guides/source/active_record_basics.textile +2 -2
  7. data/guides/source/active_record_querying.textile +32 -4
  8. data/guides/source/active_record_validations_callbacks.textile +5 -3
  9. data/guides/source/active_support_core_extensions.textile +4 -4
  10. data/guides/source/api_documentation_guidelines.textile +2 -2
  11. data/guides/source/caching_with_rails.textile +5 -5
  12. data/guides/source/command_line.textile +78 -71
  13. data/guides/source/configuring.textile +90 -74
  14. data/guides/source/contribute.textile +2 -2
  15. data/guides/source/contributing_to_ruby_on_rails.textile +3 -3
  16. data/guides/source/credits.html.erb +16 -8
  17. data/guides/source/generators.textile +3 -3
  18. data/guides/source/getting_started.textile +1 -1
  19. data/guides/source/i18n.textile +1 -1
  20. data/guides/source/initialization.textile +311 -310
  21. data/guides/source/migrations.textile +4 -4
  22. data/guides/source/rails_on_rack.textile +6 -6
  23. data/guides/source/routing.textile +1 -1
  24. data/guides/source/testing.textile +2 -2
  25. data/lib/rails/application.rb +17 -12
  26. data/lib/rails/commands.rb +1 -1
  27. data/lib/rails/commands/benchmarker.rb +3 -3
  28. data/lib/rails/commands/console.rb +2 -1
  29. data/lib/rails/commands/profiler.rb +3 -3
  30. data/lib/rails/commands/server.rb +2 -1
  31. data/lib/rails/configuration.rb +6 -0
  32. data/lib/rails/engine.rb +1 -1
  33. data/lib/rails/generators.rb +8 -2
  34. data/lib/rails/generators/css/assets/assets_generator.rb +13 -0
  35. data/lib/rails/generators/{rails/assets/templates/stylesheet.css.scss → css/assets/templates/stylesheet.css} +1 -2
  36. data/lib/rails/generators/css/scaffold/scaffold_generator.rb +16 -0
  37. data/lib/rails/generators/rails/app/app_generator.rb +1 -1
  38. data/lib/rails/generators/rails/app/templates/Gemfile +2 -2
  39. data/lib/rails/generators/rails/app/templates/config/application.rb +0 -11
  40. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +3 -0
  41. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +4 -2
  42. data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +2 -2
  43. data/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb +1 -1
  44. data/lib/rails/generators/rails/assets/USAGE +1 -1
  45. data/lib/rails/generators/rails/assets/assets_generator.rb +2 -9
  46. data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +3 -3
  47. data/lib/rails/generators/rails/plugin_new/templates/Rakefile +8 -3
  48. data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +2 -11
  49. data/lib/rails/generators/test_unit/performance/templates/performance_test.rb +1 -1
  50. data/lib/rails/railtie.rb +7 -7
  51. data/lib/rails/railtie/configurable.rb +2 -0
  52. data/lib/rails/tasks/assets.rake +12 -1
  53. data/lib/rails/tasks/documentation.rake +8 -2
  54. data/lib/rails/tasks/misc.rake +1 -1
  55. data/lib/rails/version.rb +1 -1
  56. metadata +56 -9
  57. data/lib/rails/generators/rails/scaffold/templates/scaffold.css.scss +0 -58
@@ -18,7 +18,7 @@ Rails offers four standard spots to place initialization code:
18
18
 
19
19
  h3. Running Code Before Rails
20
20
 
21
- In the rare event that your application needs to run some code before Rails itself is loaded, put it above the call to +require 'rails/all'+ in your +config/application.rb+.
21
+ In the rare event that your application needs to run some code before Rails itself is loaded, put it above the call to +require 'rails/all'+ in +config/application.rb+.
22
22
 
23
23
  h3. Configuring Rails Components
24
24
 
@@ -52,12 +52,14 @@ end
52
52
 
53
53
  * +config.asset_host+ sets the host for the assets. Useful when CDNs are used for hosting assets, or when you want to work around the concurrency constraints builtin in browsers using different domain aliases. Shorter version of +config.action_controller.asset_host+.
54
54
 
55
- * +config.asset_path+ can take a callable, a string, or be +nil+. Default is +nil+. If set, this configuration parameter let's you decorate asset paths. For example, the normal path for +blog.js+ would be +/javascripts/blog.js+, let that absolute path be +path+. If +config.asset_path+ is a callable, Rails calls it when generating asset paths passing +path+ as argument. If +config.asset_path+ is a string, it is expected to be a +sprintf+ format string with a +%s+ where +path+ will get inserted. In either case, Rails outputs the decorated path. *This option is ignored if the asset pipeline is enabled, which is by default*. Shorter version of +config.action_controller.asset_path+.
55
+ * +config.asset_path+ lets you decorate asset paths. This can be a callable, a string, or be +nil+ which is the default. For example, the normal path for +blog.js+ would be +/javascripts/blog.js+, let that absolute path be +path+. If +config.asset_path+ is a callable, Rails calls it when generating asset paths passing +path+ as argument. If +config.asset_path+ is a string, it is expected to be a +sprintf+ format string with a +%s+ where +path+ will get inserted. In either case, Rails outputs the decorated path. Shorter version of +config.action_controller.asset_path+.
56
56
 
57
57
  <ruby>
58
58
  config.asset_path = proc { |path| "/blog/public#{path}" }
59
59
  </ruby>
60
60
 
61
+ NOTE. The +config.asset_path+ configuration is ignored if the asset pipeline is enabled, which is the default.
62
+
61
63
  * +config.autoload_once_paths+ accepts an array of paths from which Rails will autoload constants that won't be wiped per request. Relevant if +config.cache_classes+ is false, which is the case in development mode by default. Otherwise, all autoloading happens only once. All elements of this array must also be in +autoload_paths+. Default is an empty array.
62
64
 
63
65
  * +config.autoload_paths+ accepts an array of paths from which Rails will autoload constants. Default is all directories under +app+.
@@ -84,11 +86,11 @@ config.asset_path = proc { |path| "/blog/public#{path}" }
84
86
 
85
87
  * +config.log_level+ defines the verbosity of the Rails logger. This option defaults to +:debug+ for all modes except production, where it defaults to +:info+.
86
88
 
87
- * +config.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ +Logger+ class. Defaults to an instance of +ActiveSupport::BufferedLogger+, with auto flushing off in production mode.
89
+ * +config.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby +Logger+ class. Defaults to an instance of +ActiveSupport::BufferedLogger+, with auto flushing off in production mode.
88
90
 
89
- * +config.middleware+ allows you to configure the application's middleware. This is covered in depth in the "Configuring Middleware":configuring-middleware section below.
91
+ * +config.middleware+ allows you to configure the application's middleware. This is covered in depth in the "Configuring Middleware":#configuring-middleware section below.
90
92
 
91
- * +config.plugins+ accepts the list of plugins to load. If this is set to +nil+, default, all plugins will be loaded. If this is set to +[]+, no plugins will be loaded. Otherwise, plugins will be loaded in the order specified. This option let's you enforce some particular loading order, useful when dependencies between plugins require it. For that use case, put first the plugins you want to be loaded in a certain order, and then the special symbol +:all+ to have the rest loaded without the need to specify them.
93
+ * +config.plugins+ accepts the list of plugins to load. The default is +nil+ in which case all plugins will be loaded. If this is set to +[]+, no plugins will be loaded. Otherwise, plugins will be loaded in the order specified. This option lets you enforce some particular loading order, useful when dependencies between plugins require it. For that use case, put first the plugins you want to be loaded in a certain order, and then the special symbol +:all+ to have the rest loaded without the need to specify them.
92
94
 
93
95
  * +config.preload_frameworks+ enables or disables preloading all frameworks at startup. Enabled by +config.threadsafe!+. Defaults to +nil+, so is disabled.
94
96
 
@@ -98,7 +100,7 @@ config.asset_path = proc { |path| "/blog/public#{path}" }
98
100
 
99
101
  * +config.serve_static_assets+ configures Rails to serve static assets. Defaults to true, but in the production environment is turned off. The server software used to run the application should be used to serve the assets instead.
100
102
 
101
- * +config.session_store+ is usually set up in +config/initializers/session_store.rb+ and specifies what class to use to store the session. Possible values are +:cookie_store+, default, +:mem_cache_store+, and +:disabled+. The last one tells Rails not to deal with sessions. Custom session stores can also be specified like so:
103
+ * +config.session_store+ is usually set up in +config/initializers/session_store.rb+ and specifies what class to use to store the session. Possible values are +:cookie_store+ which is the default, +:mem_cache_store+, and +:disabled+. The last one tells Rails not to deal with sessions. Custom session stores can also be specified:
102
104
 
103
105
  <ruby>
104
106
  config.session_store :my_custom_store
@@ -121,45 +123,49 @@ h4. Configuring Generators
121
123
  Rails 3 allows you to alter what generators are used with the +config.generators+ method. This method takes a block:
122
124
 
123
125
  <ruby>
124
- config.generators do |g|
125
- g.orm :active_record
126
- g.test_framework :test_unit
127
- end
126
+ config.generators do |g|
127
+ g.orm :active_record
128
+ g.test_framework :test_unit
129
+ end
128
130
  </ruby>
129
131
 
130
132
  The full set of methods that can be used in this block are as follows:
131
133
 
132
- * +force_plural+ allows pluralized model names. Defaults to _false_.
133
- * +helper+ defines whether or not to generate helpers. Defaults to _true_.
134
- * +orm+ defines which orm to use. Defaults to _nil_, so will use Active Record by default.
135
- * +integration_tool+ defines which integration tool to use. Defaults to _nil_.
136
- * +performance_tool+ defines which performance tool to use. Defaults to _nil_.
134
+ * +assets+ allows to create assets on generating a scaffold. Defaults to +true+.
135
+ * +force_plural+ allows pluralized model names. Defaults to +false+.
136
+ * +helper+ defines whether or not to generate helpers. Defaults to +true+.
137
+ * +integration_tool+ defines which integration tool to use. Defaults to +nil+.
138
+ * +javascripts+ turns on the hook for javascripts in generators. Used in Rails for when the +scaffold+ generator is ran. Defaults to +true+.
139
+ * +javascript_engine+ configures the engine to be used (for eg. coffee) when generating assets. Defaults to +nil+.
140
+ * +orm+ defines which orm to use. Defaults to +false+ and will use Active Record by default.
141
+ * +performance_tool+ defines which performance tool to use. Defaults to +nil+.
137
142
  * +resource_controller+ defines which generator to use for generating a controller when using +rails generate resource+. Defaults to +:controller+.
138
143
  * +scaffold_controller+ different from +resource_controller+, defines which generator to use for generating a _scaffolded_ controller when using +rails generate scaffold+. Defaults to +:scaffold_controller+.
139
- * +stylesheets+ turns on the hook for stylesheets in generators. Used in Rails for when the +scaffold+ generator is ran, but this hook can be used in other generates as well.
140
- * +test_framework+ defines which test framework to use. Defaults to _nil_, so will use Test::Unit by default.
144
+ * +stylesheets+ turns on the hook for stylesheets in generators. Used in Rails for when the +scaffold+ generator is ran, but this hook can be used in other generates as well. Defaults to +true+.
145
+ * +stylesheet_engine+ configures the stylesheet engine (for eg. sass) to be used when generating assets. Defaults to +:css+.
146
+ * +test_framework+ defines which test framework to use. Defaults to +false+ and will use Test::Unit by default.
141
147
  * +template_engine+ defines which template engine to use, such as ERB or Haml. Defaults to +:erb+.
142
148
 
143
149
  h4. Configuring Middleware
144
150
 
145
151
  Every Rails application comes with a standard set of middleware which it uses in this order in the development environment:
146
152
 
147
- * +Rack::SSL+ Will force every request to be under HTTPS protocol. Will be available if +config.force_ssl+ is set to _true_.
148
- * +ActionDispatch::Static+ is used to serve static assets. Disabled if +config.serve_static_assets+ is _true_.
149
- * +Rack::Lock+ Will wrap the app in mutex so it can only be called by a single thread at a time. Only enabled if +config.action_controller.allow_concurrency+ is set to _false_, which it is by default.
153
+ * +Rack::SSL+ Will force every request to be under HTTPS protocol. Will be available if +config.force_ssl+ is set to +true+.
154
+ * +ActionDispatch::Static+ is used to serve static assets. Disabled if +config.serve_static_assets+ is +true+.
155
+ * +Rack::Lock+ Will wrap the app in mutex so it can only be called by a single thread at a time. Only enabled if +config.action_controller.allow_concurrency+ is set to +false+, which it is by default.
150
156
  * +ActiveSupport::Cache::Strategy::LocalCache+ Serves as a basic memory backed cache. This cache is not thread safe and is intended only for serving as a temporary memory cache for a single thread.
151
157
  * +Rack::Runtime+ Sets an +X-Runtime+ header, containing the time (in seconds) taken to execute the request.
152
- * +Rails::Rack::Logger+ Will notify the logs that the request has began. After request is complete, flushes all the logs.
153
- * +ActionDispatch::ShowExceptions+ rescues any exception returned by the application and renders nice exception pages if the request is local or if +config.consider_all_requests_local+ is set to _true_. If +config.action_dispatch.show_exceptions+ is set to _false_, exceptions will be raised regardless.
154
- * +ActionDispatch::RemoteIp+ checks for IP spoofing attacks. Configurable with the +config.action_dispatch.ip_spoofing_check+ and +config.action_dispatch.trusted_proxies+ settings.
155
- * +Rack::Sendfile+ The Sendfile middleware intercepts responses whose body is being served from a file and replaces it with a server specific X-Sendfile header. Configurable with +config.action_dispatch.x_sendfile_header+
158
+ * +Rails::Rack::Logger+ Notifies the logs that the request has began. After request is complete, flushes all the logs.
159
+ * +ActionDispatch::ShowExceptions+ Rescues any exception returned by the application and renders nice exception pages if the request is local or if +config.consider_all_requests_local+ is set to +true+. If +config.action_dispatch.show_exceptions+ is set to +false+, exceptions will be raised regardless.
160
+ * +ActionDispatch::RemoteIp+ Checks for IP spoofing attacks. Configurable with the +config.action_dispatch.ip_spoofing_check+ and +config.action_dispatch.trusted_proxies+ settings.
161
+ * +Rack::Sendfile+ Intercepts responses whose body is being served from a file and replaces it with a server specific X-Sendfile header. Configurable with +config.action_dispatch.x_sendfile_header+.
156
162
  * +ActionDispatch::Callbacks+ Runs the prepare callbacks before serving the request.
157
- * +ActiveRecord::ConnectionAdapters::ConnectionManagement+ cleans active connections after each request, unless the +rack.test+ key in the request environment is set to _true_.
158
- * +ActiveRecord::QueryCache+ caches all +SELECT+ queries generated in a request. If an +INSERT+ or +UPDATE+ takes place then the cache is cleaned.
163
+ * +ActiveRecord::ConnectionAdapters::ConnectionManagement+ cleans active connections after each request, unless the +rack.test+ key in the request environment is set to +true+.
164
+ * +ActiveRecord::QueryCache+ caches all SELECT queries generated in a request. If any INSERT or UPDATE takes place then the cache is cleaned.
159
165
  * +ActionDispatch::Cookies+ sets cookies for the request.
160
166
  * +ActionDispatch::Session::CookieStore+ is responsible for storing the session in cookies. An alternate middleware can be used for this by changing the +config.action_controller.session_store+ to an alternate value. Additionally, options passed to this can be configured by using +config.action_controller.session_options+.
161
167
  * +ActionDispatch::Flash+ sets up the +flash+ keys. Only available if +config.action_controller.session_store+ is set to a value.
162
- * +ActionDispatch::ParamsParser+ parses out parameters from the request into +params+
168
+ * +ActionDispatch::ParamsParser+ parses out parameters from the request into +params+.
163
169
  * +Rack::MethodOverride+ allows the method to be overridden if +params[:_method]+ is set. This is the middleware which supports the PUT and DELETE HTTP method types.
164
170
  * +ActionDispatch::Head+ converts HEAD requests to GET requests and serves them as so.
165
171
  * +ActionDispatch::BestStandardsSupport+ enables "best standards support" so that IE8 renders some elements correctly.
@@ -167,44 +173,44 @@ Every Rails application comes with a standard set of middleware which it uses in
167
173
  Besides these usual middleware, you can add your own by using the +config.middleware.use+ method:
168
174
 
169
175
  <ruby>
170
- config.middleware.use Magical::Unicorns
176
+ config.middleware.use Magical::Unicorns
171
177
  </ruby>
172
178
 
173
- This will put the +Magical::Unicorns+ middleware on the end of the stack. If you wish to put this middleware before another use +insert_before+:
179
+ This will put the +Magical::Unicorns+ middleware on the end of the stack. You can use +insert_before+ if you wish to add a middleware before another.
174
180
 
175
181
  <ruby>
176
- config.middleware.insert_before ActionDispatch::Head, Magical::Unicorns
182
+ config.middleware.insert_before ActionDispatch::Head, Magical::Unicorns
177
183
  </ruby>
178
184
 
179
- There's also +insert_after+ which will insert a middleware _after_ another:
185
+ There's also +insert_after+ which will insert a middleware after another:
180
186
 
181
187
  <ruby>
182
- config.middleware.insert_after ActionDispatch::Head, Magical::Unicorns
188
+ config.middleware.insert_after ActionDispatch::Head, Magical::Unicorns
183
189
  </ruby>
184
190
 
185
191
  Middlewares can also be completely swapped out and replaced with others:
186
192
 
187
193
  <ruby>
188
- config.middleware.swap ActionDispatch::BestStandardsSupport, Magical::Unicorns
194
+ config.middleware.swap ActionDispatch::BestStandardsSupport, Magical::Unicorns
189
195
  </ruby>
190
196
 
191
197
  They can also be removed from the stack completely:
192
198
 
193
199
  <ruby>
194
- config.middleware.delete ActionDispatch::BestStandardsSupport
200
+ config.middleware.delete ActionDispatch::BestStandardsSupport
195
201
  </ruby>
196
202
 
197
203
  h4. Configuring i18n
198
204
 
199
205
  * +config.i18n.default_locale+ sets the default locale of an application used for i18n. Defaults to +:en+.
200
206
 
201
- * +config.i18n.load_path+ sets the path Rails uses to look for locale files. Defaults to +config/locales/*.{yml,rb}+
207
+ * +config.i18n.load_path+ sets the path Rails uses to look for locale files. Defaults to +config/locales/*.{yml,rb}+.
202
208
 
203
209
  h4. Configuring Active Record
204
210
 
205
211
  <tt>config.active_record</tt> includes a variety of configuration options:
206
212
 
207
- * +config.active_record.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby 1.8.x Logger class, which is then passed on to any new database connections made. You can retrieve this logger by calling +logger+ on either an Active Record model class or an Active Record model instance. Set to nil to disable logging.
213
+ * +config.active_record.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby Logger class, which is then passed on to any new database connections made. You can retrieve this logger by calling +logger+ on either an Active Record model class or an Active Record model instance. Set to +nil+ to disable logging.
208
214
 
209
215
  * +config.active_record.primary_key_prefix_type+ lets you adjust the naming for primary key columns. By default, Rails assumes that primary key columns are named +id+ (and this configuration option doesn't need to be set.) There are two other choices:
210
216
  ** +:table_name+ would make the primary key for the Customer class +customerid+
@@ -214,21 +220,21 @@ h4. Configuring Active Record
214
220
 
215
221
  * +config.active_record.table_name_suffix+ lets you set a global string to be appended to table names. If you set this to +_northwest+, then the Customer class will look for +customers_northwest+ as its table. The default is an empty string.
216
222
 
217
- * +config.active_record.pluralize_table_names+ specifies whether Rails will look for singular or plural table names in the database. If set to +true+ (the default), then the Customer class will use the +customers+ table. If set to +false+, then the Customers class will use the +customer+ table.
223
+ * +config.active_record.pluralize_table_names+ specifies whether Rails will look for singular or plural table names in the database. If set to +true+ (the default), then the Customer class will use the +customers+ table. If set to +false+, then the Customer class will use the +customer+ table.
218
224
 
219
- * +config.active_record.default_timezone+ determines whether to use +Time.local+ (if set to +:local+) or +Time.utc+ (if set to +:utc+) when pulling dates and times from the database. The default is +:utc+ for Rails, although ActiveRecord defaults to +:local+ when used outside of Rails.
225
+ * +config.active_record.default_timezone+ determines whether to use +Time.local+ (if set to +:local+) or +Time.utc+ (if set to +:utc+) when pulling dates and times from the database. The default is +:utc+ for Rails, although Active Record defaults to +:local+ when used outside of Rails.
220
226
 
221
227
  * +config.active_record.schema_format+ controls the format for dumping the database schema to a file. The options are +:ruby+ (the default) for a database-independent version that depends on migrations, or +:sql+ for a set of (potentially database-dependent) SQL statements.
222
228
 
223
229
  * +config.active_record.timestamped_migrations+ controls whether migrations are numbered with serial integers or with timestamps. The default is +true+, to use timestamps, which are preferred if there are multiple developers working on the same application.
224
230
 
225
- * +config.active_record.lock_optimistically+ controls whether ActiveRecord will use optimistic locking. By default this is +true+.
231
+ * +config.active_record.lock_optimistically+ controls whether Active Record will use optimistic locking. By default this is +true+.
226
232
 
227
233
  * +config.active_record.whitelist_attributes+ will create an empty whitelist of attributes available for mass-assignment security for all models in your app.
228
234
 
229
235
  The MySQL adapter adds one additional configuration option:
230
236
 
231
- * +ActiveRecord::ConnectionAdapters::MysqlAdapter.emulate_booleans+ controls whether ActiveRecord will consider all +tinyint(1)+ columns in a MySQL database to be booleans. By default this is +true+.
237
+ * +ActiveRecord::ConnectionAdapters::MysqlAdapter.emulate_booleans+ controls whether Active Record will consider all +tinyint(1)+ columns in a MySQL database to be booleans. By default this is +true+.
232
238
 
233
239
  The schema dumper adds one additional configuration option:
234
240
 
@@ -244,13 +250,13 @@ h4. Configuring Action Controller
244
250
 
245
251
  * +config.action_controller.page_cache_directory+ should be the document root for the web server and is set using <tt>Base.page_cache_directory = "/document/root"</tt>. For Rails, this directory has already been set to +Rails.public_path+ (which is usually set to <tt>Rails.root + "/public"</tt>). Changing this setting can be useful to avoid naming conflicts with files in <tt>public/</tt>, but doing so will likely require configuring your web server to look in the new location for cached files.
246
252
 
247
- * +config.action_controller.page_cache_extension+ configures the extension used for cached pages saved to +page_cache_directory+. Defaults to +.html+
253
+ * +config.action_controller.page_cache_extension+ configures the extension used for cached pages saved to +page_cache_directory+. Defaults to +.html+.
248
254
 
249
- * +config.action_controller.perform_caching+ configures whether the application should perform caching or not. Set to _false_ in development mode, _true_ in production.
255
+ * +config.action_controller.perform_caching+ configures whether the application should perform caching or not. Set to false in development mode, true in production.
250
256
 
251
257
  * +config.action_controller.default_charset+ specifies the default character set for all renders. The default is "utf-8".
252
258
 
253
- * +config.action_controller.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then used to log information from Action Controller. Set to nil to disable logging.
259
+ * +config.action_controller.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby Logger class, which is then used to log information from Action Controller. Set to +nil+ to disable logging.
254
260
 
255
261
  * +config.action_controller.request_forgery_protection_token+ sets the token parameter name for RequestForgery. Calling +protect_from_forgery+ sets it to +:authenticity_token+ by default.
256
262
 
@@ -288,36 +294,40 @@ h4. Configuring Action View
288
294
 
289
295
  There are only a few configuration options for Action View, starting with four on +ActionView::Base+:
290
296
 
291
- * +config.action_view.field_error_proc+ provides an HTML generator for displaying errors that come from Active Record. The default is <tt>Proc.new{ |html_tag, instance| %Q(%&lt;div class=&quot;field_with_errors&quot;&gt;#{html_tag}&lt;/div&gt;).html_safe }</tt>
297
+ * +config.action_view.field_error_proc+ provides an HTML generator for displaying errors that come from Active Record. The default is
298
+
299
+ <ruby>
300
+ Proc.new { |html_tag, instance| %Q(<div class="field_with_errors">#{html_tag}</div>).html_safe }
301
+ </ruby>
292
302
 
293
303
  * +config.action_view.default_form_builder+ tells Rails which form builder to use by default. The default is +ActionView::Helpers::FormBuilder+.
294
304
 
295
- * +config.action_view.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then used to log information from Action Mailer. Set to nil to disable logging.
305
+ * +config.action_view.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby Logger class, which is then used to log information from Action Mailer. Set to +nil+ to disable logging.
296
306
 
297
307
  * +config.action_view.erb_trim_mode+ gives the trim mode to be used by ERB. It defaults to +'-'+. See the "ERB documentation":http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/ for more information.
298
308
 
299
309
  * +config.action_view.javascript_expansions+ is a hash containing expansions that can be used for the JavaScript include tag. By default, this is defined as:
300
310
 
301
311
  <ruby>
302
- config.action_view.javascript_expansions = { :defaults => ['prototype', 'effects', 'dragdrop', 'controls', 'rails'] }
312
+ config.action_view.javascript_expansions = { :defaults => %w(jquery jquery_ujs) }
303
313
  </ruby>
304
314
 
305
315
  However, you may add to this by defining others:
306
316
 
307
317
  <ruby>
308
- config.action_view.javascript_expansions[:jquery] = ["jquery", "jquery-ui"]
318
+ config.action_view.javascript_expansions[:prototype] = ['prototype', 'effects', 'dragdrop', 'controls']
309
319
  </ruby>
310
320
 
311
321
  And can reference in the view with the following code:
312
322
 
313
323
  <ruby>
314
- <%= javascript_include_tag :jquery %>
324
+ <%= javascript_include_tag :prototype %>
315
325
  </ruby>
316
326
 
317
327
  * +config.action_view.stylesheet_expansions+ works in much the same way as +javascript_expansions+, but has no default key. Keys defined for this hash can be referenced in the view like such:
318
328
 
319
329
  <ruby>
320
- <%= stylesheet_link_tag :special %>
330
+ <%= stylesheet_link_tag :special %>
321
331
  </ruby>
322
332
 
323
333
  * +ActionView::Helpers::AssetTagHelper::AssetPaths.cache_asset_ids+ With the cache enabled, the asset tag helper methods will make fewer expensive file system calls (the default implementation checks the file system timestamp). However this prevents you from modifying any asset files while the server is running.
@@ -326,7 +336,7 @@ h4. Configuring Action Mailer
326
336
 
327
337
  There are a number of settings available on +config.action_mailer+:
328
338
 
329
- * +config.action_mailer.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then used to log information from Action Mailer. Set to nil to disable logging.
339
+ * +config.action_mailer.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby Logger class, which is then used to log information from Action Mailer. Set to +nil+ to disable logging.
330
340
 
331
341
  * +config.action_mailer.smtp_settings+ allows detailed configuration for the +:smtp+ delivery method. It accepts a hash of options, which can include any of these options:
332
342
  ** +:address+ - Allows you to use a remote mail server. Just change it from its default "localhost" setting.
@@ -348,17 +358,27 @@ There are a number of settings available on +config.action_mailer+:
348
358
 
349
359
  * +config.action_mailer.default+ configures Action Mailer defaults. These default to:
350
360
  <ruby>
351
- :mime_version => "1.0",
352
- :charset => "UTF-8",
353
- :content_type => "text/plain",
354
- :parts_order => [ "text/plain", "text/enriched", "text/html" ]
361
+ :mime_version => "1.0",
362
+ :charset => "UTF-8",
363
+ :content_type => "text/plain",
364
+ :parts_order => [ "text/plain", "text/enriched", "text/html" ]
365
+ </ruby>
366
+
367
+ * +config.action_mailer.observers+ registers observers which will be notified when mail is delivered.
368
+ <ruby>
369
+ config.active_record.observers = ["MailObserver"]
370
+ </ruby>
371
+
372
+ * +config.action_mailer.interceptors+ registers interceptors which will be called before mail is sent.
373
+ <ruby>
374
+ config.active_record.interceptors = ["MailInterceptor"]
355
375
  </ruby>
356
376
 
357
377
  h4. Configuring Active Resource
358
378
 
359
379
  There is a single configuration setting available on +config.active_resource+:
360
380
 
361
- * +config.active_resource.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then used to log information from Active Resource. Set to nil to disable logging.
381
+ * +config.active_resource.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby Logger class, which is then used to log information from Active Resource. Set to +nil+ to disable logging.
362
382
 
363
383
  h4. Configuring Active Support
364
384
 
@@ -398,7 +418,7 @@ Some parts of Rails can also be configured externally by supplying environment v
398
418
 
399
419
  h3. Using Initializer Files
400
420
 
401
- After loading the framework and any gems and plugins in your application, Rails turns to loading initializers. An initializer is any file of Ruby code stored under +config/initializers+ in your application. You can use initializers to hold configuration settings that should be made after all of the frameworks, plugins and gems are loaded, such as options to configure settings for these parts.
421
+ After loading the framework and any gems and plugins in your application, Rails turns to loading initializers. An initializer is any Ruby file stored under +config/initializers+ in your application. You can use initializers to hold configuration settings that should be made after all of the frameworks, plugins and gems are loaded, such as options to configure settings for these parts.
402
422
 
403
423
  NOTE: You can use subfolders to organize your initializers if you like, because Rails will look into the whole file hierarchy from the initializers folder on down.
404
424
 
@@ -406,7 +426,7 @@ TIP: If you have any ordering dependency in your initializers, you can control t
406
426
 
407
427
  h3. Initialization events
408
428
 
409
- Rails has 5 initialization events which can be hooked into (listed in order that they are ran):
429
+ Rails has 5 initialization events which can be hooked into (listed in the order that they are ran):
410
430
 
411
431
  * +before_configuration+: This is run as soon as the application constant inherits from +Rails::Application+. The +config+ calls are evaluated before this happens.
412
432
 
@@ -414,7 +434,7 @@ Rails has 5 initialization events which can be hooked into (listed in order that
414
434
 
415
435
  * +to_prepare+: Run after the initializers are ran for all Railties (including the application itself), but before eager loading and the middleware stack is built.
416
436
 
417
- * +before_eager_load+: This is run directly before eager loading occurs, which is the default behaviour for the _production_ environment and not for the +development+ enviroment.
437
+ * +before_eager_load+: This is run directly before eager loading occurs, which is the default behaviour for the _production_ environment and not for the +development+ environment.
418
438
 
419
439
  * +after_initialize+: Run directly after the initialization of the application, but before the application initializers are run.
420
440
 
@@ -437,7 +457,7 @@ Initializers defined using the +initializer+ method will be ran in the order the
437
457
 
438
458
  WARNING: You may put your initializer before or after any other initializer in the chain, as long as it is logical. Say you have 4 initializers called "one" through "four" (defined in that order) and you define "four" to go _before_ "four" but _after_ "three", that just isn't logical and Rails will not be able to determine your initializer order.
439
459
 
440
- The block's argument of the +initialize+ is the instance of the application itself, and so we can access the configuration on it by using the +config+ method as this initializer does.
460
+ The block argument of the +initializer+ method is the instance of the application itself, and so we can access the configuration on it by using the +config+ method as done in the example.
441
461
 
442
462
  Because +Rails::Application+ inherits from +Rails::Railtie+ (indirectly), you can use the +initializer+ method in +config/application.rb+ to define initializers for the application.
443
463
 
@@ -450,11 +470,11 @@ Serves as a placeholder so that +:load_environment_config+ can be defined to run
450
470
 
451
471
  *+load_active_support+* Requires +active_support/dependencies+ which sets up the basis for Active Support. Optionally requires +active_support/all+ if +config.active_support.bare+ is un-truthful, which is the default.
452
472
 
453
- *+preload_frameworks+* Will load all autoload dependencies of Rails automatically if +config.preload_frameworks+ is +true+ or "truthful". By default this configuration option is disabled. In Rails, when internal classes are referenced for the first time they are autoloaded. +:preload_frameworks+ loads all of this at once on initialization.
473
+ *+preload_frameworks+* Loads all autoload dependencies of Rails automatically if +config.preload_frameworks+ is +true+ or "truthful". By default this configuration option is disabled. In Rails, when internal classes are referenced for the first time they are autoloaded. +:preload_frameworks+ loads all of this at once on initialization.
454
474
 
455
- *+initialize_logger+* Initializes the logger (an +ActiveSupport::BufferedLogger+ object) for the application and makes it accessible at +Rails.logger+, providing that there's no initializer inserted before this point that has defined +Rails.logger+.
475
+ *+initialize_logger+* Initializes the logger (an +ActiveSupport::BufferedLogger+ object) for the application and makes it accessible at +Rails.logger+, provided that no initializer inserted before this point has defined +Rails.logger+.
456
476
 
457
- *+initialize_cache+* If +RAILS_CACHE+ isn't yet set, initializes the cache by referencing the value in +config.cache_store+ and stores the outcome as +RAILS_CACHE+. If this object responds to the +middleware+ method, its middleware is inserted before +Rack::Runtime+ in the middleware stack.
477
+ *+initialize_cache+* If +RAILS_CACHE+ isn't set yet, initializes the cache by referencing the value in +config.cache_store+ and stores the outcome as +RAILS_CACHE+. If this object responds to the +middleware+ method, its middleware is inserted before +Rack::Runtime+ in the middleware stack.
458
478
 
459
479
  *+set_clear_dependencies_hook+* Provides a hook for +active_record.set_dispatch_hooks+ to use, which will run before this initializer. This initializer -- which runs only if +cache_classes+ is set to +false+ -- uses +ActionDispatch::Callbacks.after+ to remove the constants which have been referenced during the request from the object space so that they will be reloaded during the following request.
460
480
 
@@ -464,7 +484,7 @@ Serves as a placeholder so that +:load_environment_config+ can be defined to run
464
484
 
465
485
  *+i18n.callbacks+* In the development environment, sets up a +to_prepare+ callback which will call +I18n.reload!+ if any of the locales have changed since the last request. In production mode this callback will only run on the first request.
466
486
 
467
- *+active_support.initialize_whiny_nils+* Will require +active_support/whiny_nil+ if +config.whiny_nils+ is set to +true+. This file will output errors such as:
487
+ *+active_support.initialize_whiny_nils+* Requires +active_support/whiny_nil+ if +config.whiny_nils+ is set to +true+. This file will output errors such as:
468
488
 
469
489
  <plain>
470
490
  Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
@@ -480,19 +500,19 @@ The error occurred while evaluating nil.each
480
500
 
481
501
  *+active_support.deprecation_behavior+* Sets up deprecation reporting for environments, defaulting to +:log+ for development, +:notify+ for production and +:stderr+ for test. If a value isn't set for +config.active_support.deprecation+ then this initializer will prompt the user to configure this line in the current environment's +config/environments+ file. Can be set to an array of values.
482
502
 
483
- *+active_support.initialize_time_zone+* Sets the default time zone for the application based off the +config.time_zone+ setting, which defaults to "UTC".
503
+ *+active_support.initialize_time_zone+* Sets the default time zone for the application based on the +config.time_zone+ setting, which defaults to "UTC".
484
504
 
485
505
  *+action_dispatch.configure+* Configures the +ActionDispatch::Http::URL.tld_length+ to be set to the value of +config.action_dispatch.tld_length+.
486
506
 
487
- *+action_view.cache_asset_ids+* Will set +ActionView::Helpers::AssetTagHelper::AssetPaths.cache_asset_ids+ to +false+ when Active Support loads, but only if +config.cache_classes+ is too.
507
+ *+action_view.cache_asset_ids+* Sets +ActionView::Helpers::AssetTagHelper::AssetPaths.cache_asset_ids+ to +false+ when Active Support loads, but only if +config.cache_classes+ is too.
488
508
 
489
509
  *+action_view.javascript_expansions+* Registers the expansions set up by +config.action_view.javascript_expansions+ and +config.action_view.stylesheet_expansions+ to be recognised by Action View and therefore usable in the views.
490
510
 
491
511
  *+action_view.set_configs+* Sets up Action View by using the settings in +config.action_view+ by +send+'ing the method names as setters to +ActionView::Base+ and passing the values through.
492
512
 
493
- *+action_controller.logger+* Sets +ActionController::Base.logger+ -- if it's not already set -- to +Rails.logger+.
513
+ *+action_controller.logger+* Sets +ActionController::Base.logger+ -- if it's not already set -- to +Rails.logger+.
494
514
 
495
- *+action_controller.initialize_framework_caches+* Sets +ActionController::Base.cache_store+ -- if it's not already set -- to +RAILS_CACHE+.
515
+ *+action_controller.initialize_framework_caches+* Sets +ActionController::Base.cache_store+ -- if it's not already set -- to +RAILS_CACHE+.
496
516
 
497
517
  *+action_controller.set_configs+* Sets up Action Controller by using the settings in +config.action_controller+ by +send+'ing the method names as setters to +ActionController::Base+ and passing the values through.
498
518
 
@@ -506,9 +526,9 @@ The error occurred while evaluating nil.each
506
526
 
507
527
  *+active_record.initialize_database+* Loads the database configuration (by default) from +config/database.yml+ and establishes a connection for the current environment.
508
528
 
509
- *+active_record.log_runtime+* Includes +ActiveRecord::Railties::ControllerRuntime+ which is responsible for reporting the length of time Active Record calls took for the request back to the logger.
529
+ *+active_record.log_runtime+* Includes +ActiveRecord::Railties::ControllerRuntime+ which is responsible for reporting the time taken by Active Record calls for the request back to the logger.
510
530
 
511
- *+active_record.set_dispatch_hooks+* If +config.cache_classes+ is set to false, all reloadable connections to the database will be reset.
531
+ *+active_record.set_dispatch_hooks+* Resets all reloadable connections to the database if +config.cache_classes+ is set to +false+.
512
532
 
513
533
  *+action_mailer.logger+* Sets +ActionMailer::Base.logger+ -- if it's not already set -- to +Rails.logger+.
514
534
 
@@ -536,10 +556,6 @@ The error occurred while evaluating nil.each
536
556
 
537
557
  *+load_config_initializers+* Loads all Ruby files from +config/initializers+ in the application, railties and engines. The files in this directory can be used to hold configuration settings that should be made after all of the frameworks and plugins are loaded.
538
558
 
539
- NOTE: You can use subfolders to organize your initializers if you like, because Rails will look into the whole file hierarchy from the +initializers+ folder on down.
540
-
541
- TIP: If you have any ordering dependency in your initializers, you can control the load order by naming. For example, +01_critical.rb+ will be loaded before +02_normal.rb+.
542
-
543
559
  *+engines_blank_point+* Provides a point-in-initialization to hook into if you wish to do anything before engines are loaded. After this point, all railtie and engine initializers are ran.
544
560
 
545
561
  *+add_generator_templates+* Finds templates for generators at +lib/templates+ for the application, railities and engines and adds these to the +config.generators.templates+ setting, which will make the templates available for all generators to reference.
@@ -566,4 +582,4 @@ h3. Changelog
566
582
  * November 26, 2010: Removed all config settings not available in Rails 3 ("Ryan Bigg":http://ryanbigg.com)
567
583
  * August 13, 2009: Updated with config syntax and added general configuration options by "John Pignata"
568
584
  * January 3, 2009: First reasonably complete draft by "Mike Gunderloy":credits.html#mgunderloy
569
- * November 5, 2008: Rough outline by "Mike Gunderloy":credits.html#mgunderloy
585
+ * November 5, 2008: Rough outline by "Mike Gunderloy":credits.html#mgunderloy
@@ -33,7 +33,7 @@ h3. What to Contribute?
33
33
  h3. How is the process?
34
34
 
35
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. In that case feedback can be given in its LH ticket.
36
+ * A new guide is only edited by its author until finished though.
37
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
38
  * Guides reviewers will then provide feedback, some of it possibly in form of direct commits to agilize the process.
39
39
  * Eventually the guide will be approved and added to the index.
@@ -53,7 +53,7 @@ h3. Rules
53
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
54
  * Our review team will have the final say on whether the guide is complete and of good enough quality.
55
55
 
56
- All authors should read and follow the "Rails Guides Conventions":https://wiki.github.com/lifo/docrails/rails-guides-conventions and the "Rails API Documentation Conventions":https://wiki.github.com/lifo/docrails/rails-api-documentation-conventions.
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
57
 
58
58
  h3. Translations
59
59
 
@@ -24,7 +24,7 @@ If you've found a problem in Ruby on Rails which is not a security risk do a sea
24
24
 
25
25
  At the minimum, your issue report needs a title and descriptive text. But that's only a minimum. You should include as much relevant information as possible. You need to at least post the code sample that has the issue. Even better is to include a unit test that shows how the expected behavior is not occurring. Your goal should be to make it easy for yourself - and others - to replicate the bug and figure out a fix.
26
26
 
27
- Then don't get your hopes up. Unless you have a "Code Red, Mission Critical, The World is Coming to an End" kind of bug, you're creating this issue report in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the issue report will automatically see any activity or that others will jump to fix it. Creating a issue like this is mostly to help yourself start on the path of fixing the problem and for others to confirm it with a "I'm having this problem too" comment.
27
+ Then don't get your hopes up. Unless you have a "Code Red, Mission Critical, The World is Coming to an End" kind of bug, you're creating this issue report in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the issue report will automatically see any activity or that others will jump to fix it. Creating an issue like this is mostly to help yourself start on the path of fixing the problem and for others to confirm it with a "I'm having this problem too" comment.
28
28
 
29
29
  h4. Special Treatment for Security Issues
30
30
 
@@ -90,7 +90,7 @@ This command will install all dependencies except the MySQL and PostgreSQL Ruby
90
90
  $ rake test
91
91
  </shell>
92
92
 
93
- You can also run tests for an specific framework, like Action Pack, by going into its directory and executing the same command:
93
+ You can also run tests for a specific framework, like Action Pack, by going into its directory and executing the same command:
94
94
 
95
95
  <shell>
96
96
  $ cd actionpack
@@ -264,7 +264,7 @@ When working with documentation, please take into account the "API Documentation
264
264
 
265
265
  NOTE: As explained above, ordinary code patches should have proper documentation coverage. docrails is only used for isolated documentation improvements.
266
266
 
267
- 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.
267
+ 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
268
 
269
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
270