aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2012-11-03 01:56:16 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2012-11-03 01:56:16 +0530
commit3b0bb08699ce409b8213c82956dc34086dcbc8b9 (patch)
tree34398e3421fcfd86aab2b5fc757175dd2ce7664d /guides/source
parent974467d70d337d4c60414c792e275d367143217b (diff)
parentee917493e451e552fef18367f8bcba2f36080685 (diff)
downloadrails-3b0bb08699ce409b8213c82956dc34086dcbc8b9.tar.gz
rails-3b0bb08699ce409b8213c82956dc34086dcbc8b9.tar.bz2
rails-3b0bb08699ce409b8213c82956dc34086dcbc8b9.zip
Merge branch 'master' of github.com:lifo/docrails
Conflicts: actionpack/lib/action_controller/metal/mime_responds.rb activerecord/lib/active_record/attribute_methods.rb guides/source/working_with_javascript_in_rails.md
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/3_1_release_notes.md4
-rw-r--r--guides/source/action_controller_overview.md2
-rw-r--r--guides/source/active_record_querying.md4
-rw-r--r--guides/source/active_record_validations_callbacks.md4
-rw-r--r--guides/source/active_support_core_extensions.md36
-rw-r--r--guides/source/active_support_instrumentation.md4
-rw-r--r--guides/source/asset_pipeline.md3
-rw-r--r--guides/source/configuring.md2
-rw-r--r--guides/source/contributing_to_ruby_on_rails.md1
-rw-r--r--guides/source/i18n.md2
-rw-r--r--guides/source/layouts_and_rendering.md6
-rw-r--r--guides/source/migrations.md5
-rw-r--r--guides/source/upgrading_ruby_on_rails.md4
-rw-r--r--guides/source/working_with_javascript_in_rails.md1
14 files changed, 46 insertions, 32 deletions
diff --git a/guides/source/3_1_release_notes.md b/guides/source/3_1_release_notes.md
index 1d79ea5b5a..d3f8abe0c8 100644
--- a/guides/source/3_1_release_notes.md
+++ b/guides/source/3_1_release_notes.md
@@ -129,6 +129,10 @@ config.static_cache_control = "public, max-age=3600"
end
```
+#### Remove :cache and :concat options in asset helpers references in views
+
+* With the Asset Pipeline the :cache and :concat options aren't used anymore, delete these options from your views.
+
Creating a Rails 3.1 application
--------------------------------
diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md
index 824ffb5d7a..dd8d229e6a 100644
--- a/guides/source/action_controller_overview.md
+++ b/guides/source/action_controller_overview.md
@@ -66,7 +66,7 @@ class ClientsController < ActionController::Base
if params[:status] == "activated"
@clients = Client.activated
else
- @clients = Client.unactivated
+ @clients = Client.inactivated
end
end
diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md
index 76548a3397..da56d55deb 100644
--- a/guides/source/active_record_querying.md
+++ b/guides/source/active_record_querying.md
@@ -1087,7 +1087,7 @@ Scopes
Scoping allows you to specify commonly-used queries which can be referenced as method calls on the association objects or models. With these scopes, you can use every method previously covered such as `where`, `joins` and `includes`. All scope methods will return an `ActiveRecord::Relation` object which will allow for further methods (such as other scopes) to be called on it.
-To define a simple scope, we use the `scope` method inside the class, passing the query that we'd like run when this scope is called:
+To define a simple scope, we use the `scope` method inside the class, passing the query that we'd like to run when this scope is called:
```ruby
class Post < ActiveRecord::Base
@@ -1256,7 +1256,7 @@ creating a new record, but we don't want to include it in the query. So
we want to find the client named "Andy", or if that client doesn't
exist, create a client named "Andy" which is not locked.
-We can achive this in two ways. The first is to use `create_with`:
+We can achieve this in two ways. The first is to use `create_with`:
```ruby
Client.create_with(locked: false).find_or_create_by(first_name: 'Andy')
diff --git a/guides/source/active_record_validations_callbacks.md b/guides/source/active_record_validations_callbacks.md
index 7555ef4226..5c27ccbf9e 100644
--- a/guides/source/active_record_validations_callbacks.md
+++ b/guides/source/active_record_validations_callbacks.md
@@ -736,7 +736,7 @@ end
person = Person.new
person.valid? # => false
person.errors
- # => {name: ["can't be blank", "is too short (minimum is 3 characters)"]}
+ # => {:name=>["can't be blank", "is too short (minimum is 3 characters)"]}
person = Person.new(name: "John Doe")
person.valid? # => true
@@ -1003,7 +1003,7 @@ Callbacks can also be registered to only fire on certain lifecycle events:
```ruby
class User < ActiveRecord::Base
before_validation :normalize_name, on: :create
-
+
# :on takes an array as well
after_validation :set_location, on: [ :create, :update ]
diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md
index 122257807b..4b2cc947b5 100644
--- a/guides/source/active_support_core_extensions.md
+++ b/guides/source/active_support_core_extensions.md
@@ -2372,7 +2372,7 @@ This method is similar in purpose to `Kernel#Array`, but there are some differen
The last point is particularly worth comparing for some enumerables:
```ruby
-Array.wrap(foo: :bar) # => [{foo: :bar}]
+Array.wrap(foo: :bar) # => [{:foo=>:bar}]
Array(foo: :bar) # => [[:foo, :bar]]
```
@@ -2557,7 +2557,7 @@ Ruby has a built-in method `Hash#merge` that merges two hashes:
```ruby
{a: 1, b: 1}.merge(a: 0, c: 2)
-# => {a: 0, b: 1, c: 2}
+# => {:a=>0, :b=>1, :c=>2}
```
Active Support defines a few more ways of merging hashes that may be convenient.
@@ -2602,7 +2602,7 @@ Active Support defines `Hash#deep_merge`. In a deep merge, if a key is found in
```ruby
{a: {b: 1}}.deep_merge(a: {c: 2})
-# => {a: {b: 1, c: 2}}
+# => {:a=>{:b=>1, :c=>2}}
```
The method `deep_merge!` performs a deep merge in place.
@@ -2641,17 +2641,17 @@ The method `diff` returns a hash that represents a diff of the receiver and the
# => {}, first rule
{a: 1}.diff(a: 2)
-# => {a: 1}, second rule
+# => {:a=>1}, second rule
{a: 1}.diff(b: 2)
-# => {a: 1, b: 2}, third rule
+# => {:a=>1, :b=>2}, third rule
{a: 1, b: 2, c: 3}.diff(b: 1, c: 3, d: 4)
-# => {a: 1, b: 2, d: 4}, all rules
+# => {:a=>1, :b=>2, :d=>4}, all rules
{}.diff({}) # => {}
-{a: 1}.diff({}) # => {a: 1}
-{}.diff(a: 1) # => {a: 1}
+{a: 1}.diff({}) # => {:a=>1}
+{}.diff(a: 1) # => {:a=>1}
```
An important property of this diff hash is that you can retrieve the original hash by applying `diff` twice:
@@ -2671,7 +2671,7 @@ NOTE: Defined in `active_support/core_ext/hash/diff.rb`.
The method `except` returns a hash with the keys in the argument list removed, if present:
```ruby
-{a: 1, b: 2}.except(:a) # => {b: 2}
+{a: 1, b: 2}.except(:a) # => {:b=>2}
```
If the receiver responds to `convert_key`, the method is called on each of the arguments. This allows `except` to play nice with hashes with indifferent access for instance:
@@ -2776,7 +2776,7 @@ The method `symbolize_keys` returns a hash that has a symbolized version of the
```ruby
{nil => nil, 1 => 1, "a" => "a"}.symbolize_keys
-# => {1 => 1, nil => nil, a: "a"}
+# => {1=>1, nil=>nil, :a=>"a"}
```
WARNING. Note in the previous example only one key was symbolized.
@@ -2785,7 +2785,7 @@ The result in case of collision is undefined:
```ruby
{"a" => 1, a: 2}.symbolize_keys
-# => {a: 2}, in my test, can't rely on this result though
+# => {:a=>2}, in my test, can't rely on this result though
```
This method may be useful for example to easily accept both symbols and strings as options. For instance `ActionController::UrlRewriter` defines
@@ -2836,17 +2836,17 @@ Ruby has built-in support for taking slices out of strings and arrays. Active Su
```ruby
{a: 1, b: 2, c: 3}.slice(:a, :c)
-# => {c: 3, a: 1}
+# => {:c=>3, :a=>1}
{a: 1, b: 2, c: 3}.slice(:b, :X)
-# => {b: 2} # non-existing keys are ignored
+# => {:b=>2} # non-existing keys are ignored
```
If the receiver responds to `convert_key` keys are normalized:
```ruby
{a: 1, b: 2}.with_indifferent_access.slice("a")
-# => {a: 1}
+# => {:a=>1}
```
NOTE. Slicing may come in handy for sanitizing option hashes with a white list of keys.
@@ -2855,8 +2855,8 @@ There's also `slice!` which in addition to perform a slice in place returns what
```ruby
hash = {a: 1, b: 2}
-rest = hash.slice!(:a) # => {b: 2}
-hash # => {a: 1}
+rest = hash.slice!(:a) # => {:b=>2}
+hash # => {:a=>1}
```
NOTE: Defined in `active_support/core_ext/hash/slice.rb`.
@@ -2867,8 +2867,8 @@ The method `extract!` removes and returns the key/value pairs matching the given
```ruby
hash = {a: 1, b: 2}
-rest = hash.extract!(:a) # => {a: 1}
-hash # => {b: 2}
+rest = hash.extract!(:a) # => {:a=>1}
+hash # => {:b=>2}
```
The method `extract!` returns the same subclass of Hash, that the receiver is.
diff --git a/guides/source/active_support_instrumentation.md b/guides/source/active_support_instrumentation.md
index b35691bbcc..1163940f10 100644
--- a/guides/source/active_support_instrumentation.md
+++ b/guides/source/active_support_instrumentation.md
@@ -434,7 +434,7 @@ ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*a
event.name # => "process_action.action_controller"
event.duration # => 10 (in milliseconds)
- event.payload # => { extra: :information }
+ event.payload # => {:extra=>information}
Rails.logger.info "#{event} Received!"
end
@@ -477,7 +477,7 @@ Now you can listen to this event with:
```ruby
ActiveSupport::Notifications.subscribe "my.custom.event" do |name, started, finished, unique_id, data|
- puts data.inspect # { this: :data }
+ puts data.inspect # {:this=>:data}
end
```
diff --git a/guides/source/asset_pipeline.md b/guides/source/asset_pipeline.md
index fc0092a93e..0540516a74 100644
--- a/guides/source/asset_pipeline.md
+++ b/guides/source/asset_pipeline.md
@@ -386,6 +386,9 @@ generates something like this:
<link href="/assets/application-4dd5b109ee3439da54f5bdfd78a80473.css" media="screen" rel="stylesheet" />
```
+Note: with the Asset Pipeline the :cache and :concat options aren't used anymore, delete these options from the `javascript_include_tag` and `stylesheet_link_tag`.
+
+
The fingerprinting behavior is controlled by the setting of `config.assets.digest` setting in Rails (which defaults to `true` for production and `false` for everything else).
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.
diff --git a/guides/source/configuring.md b/guides/source/configuring.md
index ab2766054b..0b4f183d61 100644
--- a/guides/source/configuring.md
+++ b/guides/source/configuring.md
@@ -133,7 +133,7 @@ These configuration methods are to be called on a `Rails::Railtie` object, such
### Configuring Assets
-Rails 3.1, by default, is set up to use the `sprockets` gem to manage assets within an application. This gem concatenates and compresses assets in order to make serving them much less painful.
+Rails 3.1 and up, by default, is set up to use the `sprockets` gem to manage assets within an application. This gem concatenates and compresses assets in order to make serving them much less painful.
* `config.assets.enabled` a flag that controls whether the asset pipeline is enabled. It is explicitly initialized in `config/application.rb`.
diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md
index 6e843062ec..3791467584 100644
--- a/guides/source/contributing_to_ruby_on_rails.md
+++ b/guides/source/contributing_to_ruby_on_rails.md
@@ -208,6 +208,7 @@ Rails follows a simple set of coding style conventions.
* Two spaces, no tabs (for indentation).
* No trailing whitespace. Blank lines should not have any spaces.
* Indent after private/protected.
+* Use Ruby >= 1.9 syntax for hashes. Prefer `{ a: :b }` over `{ :a => :b }`.
* Prefer `&&`/`||` over `and`/`or`.
* Prefer class << self over self.method for class methods.
* Use `MyClass.my_method(my_arg)` not `my_method( my_arg )` or `my_method my_arg`.
diff --git a/guides/source/i18n.md b/guides/source/i18n.md
index e916bda630..9d8287ab7c 100644
--- a/guides/source/i18n.md
+++ b/guides/source/i18n.md
@@ -546,7 +546,7 @@ Also, a key can translate to a (potentially nested) hash of grouped translations
```ruby
I18n.t 'activerecord.errors.messages'
-# => { inclusion: "is not included in the list", exclusion: ... }
+# => {:inclusion=>"is not included in the list", :exclusion=> ... }
```
#### "Lazy" Lookup
diff --git a/guides/source/layouts_and_rendering.md b/guides/source/layouts_and_rendering.md
index 8277859232..5f4f7e8511 100644
--- a/guides/source/layouts_and_rendering.md
+++ b/guides/source/layouts_and_rendering.md
@@ -124,7 +124,7 @@ Cache-Control: no-cache
$
```
-We see there is an empty response (no data after the `Cache-Control` line), but the request was successful because Rails has set the response to 200 OK. You can set the `:status` option on render to change this response. Rendering nothing can be useful for AJAX requests where all you want to send back to the browser is an acknowledgment that the request was completed.
+We see there is an empty response (no data after the `Cache-Control` line), but the request was successful because Rails has set the response to 200 OK. You can set the `:status` option on render to change this response. Rendering nothing can be useful for Ajax requests where all you want to send back to the browser is an acknowledgment that the request was completed.
TIP: You should probably be using the `head` method, discussed later in this guide, instead of `render :nothing`. This provides additional flexibility and makes it explicit that you're only generating HTTP headers.
@@ -259,13 +259,13 @@ You can send plain text - with no markup at all - back to the browser by using t
render :text => "OK"
```
-TIP: Rendering pure text is most useful when you're responding to AJAX or web service requests that are expecting something other than proper HTML.
+TIP: Rendering pure text is most useful when you're responding to Ajax or web service requests that are expecting something other than proper HTML.
NOTE: By default, if you use the `:text` option, the text is rendered without using the current layout. If you want Rails to put the text into the current layout, you need to add the `:layout => true` option.
#### Rendering JSON
-JSON is a JavaScript data format used by many AJAX libraries. Rails has built-in support for converting objects to JSON and rendering that JSON back to the browser:
+JSON is a JavaScript data format used by many Ajax libraries. Rails has built-in support for converting objects to JSON and rendering that JSON back to the browser:
```ruby
render :json => @product
diff --git a/guides/source/migrations.md b/guides/source/migrations.md
index 3eeb45f8c6..314ee3f5cd 100644
--- a/guides/source/migrations.md
+++ b/guides/source/migrations.md
@@ -684,8 +684,9 @@ version to migrate to.
The `rake db:reset` task will drop the database, recreate it and load the
current schema into it.
-NOTE: This is not the same as running all the migrations - see the section on
-[schema.rb](#schema-dumping-and-you).
+NOTE: This is not the same as running all the migrations. It will only use the contents
+of the current schema.rb file. If a migration can't be rolled back, 'rake db:reset'
+may not help you. To find out more about dumping the schema see [schema.rb](#schema-dumping-and-you).
### Running Specific Migrations
diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md
index d57bb1f8bc..05a1714966 100644
--- a/guides/source/upgrading_ruby_on_rails.md
+++ b/guides/source/upgrading_ruby_on_rails.md
@@ -271,3 +271,7 @@ or
```bash
$ rake db:sessions:clear
```
+
+### Remove :cache and :concat options in asset helpers references in views
+
+* With the Asset Pipeline the :cache and :concat options aren't used anymore, delete these options from your views.
diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md
index bb736eb670..011303c311 100644
--- a/guides/source/working_with_javascript_in_rails.md
+++ b/guides/source/working_with_javascript_in_rails.md
@@ -138,6 +138,7 @@ and Rails has got your back in those cases.
Because of Unobtrusive JavaScript, the Rails "Ajax helpers" are actually in two
parts: the JavaScript half and the Ruby half.
+
[rails.js](https://github.com/rails/jquery-ujs/blob/master/src/rails.js)
provides the JavaScript half, and the regular Ruby view helpers add appropriate
tags to your DOM. The CoffeeScript in rails.js then listens for these