diff options
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/4_1_release_notes.md | 26 | ||||
-rw-r--r-- | guides/source/asset_pipeline.md | 27 | ||||
-rw-r--r-- | guides/source/engines.md | 7 | ||||
-rw-r--r-- | guides/source/getting_started.md | 8 | ||||
-rw-r--r-- | guides/source/migrations.md | 8 | ||||
-rw-r--r-- | guides/source/routing.md | 2 | ||||
-rw-r--r-- | guides/source/testing.md | 2 |
7 files changed, 55 insertions, 25 deletions
diff --git a/guides/source/4_1_release_notes.md b/guides/source/4_1_release_notes.md index 5c621d0a1b..171572c77c 100644 --- a/guides/source/4_1_release_notes.md +++ b/guides/source/4_1_release_notes.md @@ -153,8 +153,8 @@ end The preview is available in http://localhost:3000/rails/mailers/notifier/welcome, and a list of them in http://localhost:3000/rails/mailers. -By default, these preview classes live in <tt>test/mailers/previews</tt>. -This can be configured using the <tt>preview_path</tt> option. +By default, these preview classes live in `test/mailers/previews`. +This can be configured using the `preview_path` option. See its [documentation](http://api.rubyonrails.org/v4.1.0/classes/ActionMailer/Base.html) @@ -181,20 +181,22 @@ See its [documentation](http://api.rubyonrails.org/v4.1.0/classes/ActiveRecord/Enum.html) for a detailed write up. -### Application Message Verifier +### Message Verifiers -The application message verifier can be used to generate and verify signed -messages in the application. This can be useful for remember-me tokens and -friends: +Message verifiers can be used to generate and verify signed messages. This can +be useful to safely transport sensitive data like remember-me tokens and +friends. + +The method `Rails.application.message_verifier` returns a new message verifier +that signs messages with a key derived from secret_key_base and the given +message verifier name: ```ruby -signed_message = Rails.application.message_verifier('salt').generate('my sensible data') -Rails.application.message_verifier('salt').verify(signed_message) -# => 'my sensible data' +signed_token = Rails.application.message_verifier(:remember_me).generate(token) +Rails.application.message_verifier(:remember_me).verify(signed_token) # => token -Rails.application.message_verifier('salt').verify(tampered_message) +Rails.application.message_verifier(:remember_me).verify(tampered_token) # raises ActiveSupport::MessageVerifier::InvalidSignature - ``` ### Module#concerning @@ -364,7 +366,7 @@ for detailed changes. * Removed deprecated `increment_open_transactions`. * Removed deprecated `PostgreSQLAdapter#outside_transaction?` - methodd. You can use `#transaction_open?` instead. + method. You can use `#transaction_open?` instead. * Removed deprecated `ActiveRecord::Fixtures.find_table_name` in favor of `ActiveRecord::Fixtures.default_fixture_model_name`. diff --git a/guides/source/asset_pipeline.md b/guides/source/asset_pipeline.md index 7d1b633c5f..bce5d6c55f 100644 --- a/guides/source/asset_pipeline.md +++ b/guides/source/asset_pipeline.md @@ -577,6 +577,33 @@ would generate this HTML: The `body` param is required by Sprockets. +### Runtime Error Checking + +By default the asset pipeline will check for potential errors in development mode during +runtime. To disable this behavior you can set: + +```ruby +config.assets.raise_runtime_errors = false +``` + +When `raise_runtime_errors` is set to `false` sprockets will not check that dependencies of assets are declared properly. Here is a scenario where you must tell the asset pipeline about a dependency: + +If you have `application.css.erb` that references `logo.png` like this: + +```css +#logo { background: url(<%= asset_data_uri 'logo.png' %>) } +``` + +Then you must declare that `logo.png` is a dependency of `application.css.erb`, so when the image gets re-compiled, the css file does as well. You can do this using the `//= depend_on_asset` declaration: + +```css +//= depend_on_asset "logo.png" +#logo { background: url(<%= asset_data_uri 'logo.png' %>) } +``` + +Without this declaration you may experience strange behavior when pushing to production that is difficult to debug. When you have `raise_runtime_errors` set to `true`, dependencies will be checked at runtime so you can ensure that all dependencies are met. + + ### Turning Debugging Off You can turn off debug mode by updating `config/environments/development.rb` to diff --git a/guides/source/engines.md b/guides/source/engines.md index 87b0a1ac16..bbd63bb892 100644 --- a/guides/source/engines.md +++ b/guides/source/engines.md @@ -959,8 +959,8 @@ self.author = Blorgh.author_class.find_or_create_by(name: author_name) Resulting in something a little shorter, and more implicit in its behavior. The `author_class` method should always return a `Class` object. -Since we changed the `author_class` method to return a `String` instead of a -`Class`, we must also modify our `belongs_to` definition in the `Blorgh::Post` +Since we changed the `author_class` method to return a `Class` instead of a +`String`, we must also modify our `belongs_to` definition in the `Blorgh::Post` model: ```ruby @@ -1014,7 +1014,8 @@ application. The same thing goes if you want to use a standard initializer. For locales, simply place the locale files in the `config/locales` directory, just like you would in an application. -Testing an engine ----------------- +Testing an engine +----------------- When an engine is generated, there is a smaller dummy application created inside it at `test/dummy`. This application is used as a mounting point for the engine, diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index 279a977f6f..afb3bb22bf 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -86,7 +86,7 @@ current version of Ruby installed: ```bash $ ruby -v -ruby 2.0.0p247 +ruby 2.0.0p353 ``` To install Rails, use the `gem install` command provided by RubyGems: @@ -1703,8 +1703,8 @@ Deleting Comments ----------------- Another important feature of a blog is being able to delete spam comments. To do -this, we need to implement a link of some sort in the view and a `DELETE` action -in the `CommentsController`. +this, we need to implement a link of some sort in the view and a `destroy` +action in the `CommentsController`. So first, let's add the delete link in the `app/views/comments/_comment.html.erb` partial: @@ -1729,7 +1729,7 @@ So first, let's add the delete link in the Clicking this new "Destroy Comment" link will fire off a `DELETE /posts/:post_id/comments/:id` to our `CommentsController`, which can then use -this to find the comment we want to delete, so let's add a destroy action to our +this to find the comment we want to delete, so let's add a `destroy` action to our controller (`app/controllers/comments_controller.rb`): ```ruby diff --git a/guides/source/migrations.md b/guides/source/migrations.md index 71a177bca7..5d5c2724b1 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -297,10 +297,10 @@ You can append as many column name/type pairs as you want. You can also specify some options just after the field type between curly braces. You can use the following modifiers: -* `limit` Sets the maximum size of the `string/text/binary/integer` fields -* `precision` Defines the precision for the `decimal` fields -* `scale` Defines the scale for the `decimal` fields -* `polymorphic` Adds a `type` column for `belongs_to` associations +* `limit` Sets the maximum size of the `string/text/binary/integer` fields. +* `precision` Defines the precision for the `decimal` fields, representing the total number of digits in the number. +* `scale` Defines the scale for the `decimal` fields, representing the number of digits after the decimal point. +* `polymorphic` Adds a `type` column for `belongs_to` associations. * `null` Allows or disallows `NULL` values in the column. For instance, running: diff --git a/guides/source/routing.md b/guides/source/routing.md index 019861c3d6..3375293b5a 100644 --- a/guides/source/routing.md +++ b/guides/source/routing.md @@ -138,7 +138,7 @@ Sometimes, you have a resource that clients always look up without referencing a get 'profile', to: 'users#show' ``` -Passing a `String` to `match` will expect a `controller#action` format, while passing a `Symbol` will map directly to an action: +Passing a `String` to `get` will expect a `controller#action` format, while passing a `Symbol` will map directly to an action: ```ruby get 'profile', to: :show diff --git a/guides/source/testing.md b/guides/source/testing.md index d00fcd1f03..165eca739a 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -784,7 +784,7 @@ class UserFlowsTest < ActionDispatch::IntegrationTest u = users(user) sess.https! sess.post "/login", username: u.username, password: u.password - assert_equal '/welcome', path + assert_equal '/welcome', sess.path sess.https!(false) end end |