aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2012-02-28 19:07:44 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2012-02-28 19:07:44 +0530
commitf597122b076568356c070ed9bcd83aec29a963eb (patch)
tree25f950f04a18167329d4f1de0fdd44eea7bd9cd4 /railties/guides/source
parent699ba8ab52973bf0499643235f162734fb644ab7 (diff)
parent547e695551e223e4d92762d3c176187e6780e524 (diff)
downloadrails-f597122b076568356c070ed9bcd83aec29a963eb.tar.gz
rails-f597122b076568356c070ed9bcd83aec29a963eb.tar.bz2
rails-f597122b076568356c070ed9bcd83aec29a963eb.zip
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'railties/guides/source')
-rw-r--r--railties/guides/source/active_record_validations_callbacks.textile12
-rw-r--r--railties/guides/source/caching_with_rails.textile2
-rw-r--r--railties/guides/source/layouts_and_rendering.textile2
-rw-r--r--railties/guides/source/routing.textile6
4 files changed, 20 insertions, 2 deletions
diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile
index 72ac8d2db9..349d02c1f6 100644
--- a/railties/guides/source/active_record_validations_callbacks.textile
+++ b/railties/guides/source/active_record_validations_callbacks.textile
@@ -517,6 +517,18 @@ class Person < ActiveRecord::Base
end
</ruby>
+h3. Strict Validations
+
+You can also specify validations to be strict and raise +ActiveModel::StrictValidationFailed+ when the object is invalid.
+
+<ruby>
+class Person < ActiveRecord::Base
+ validates :name, :presence => { :strict => true }
+end
+
+Person.new.valid? => ActiveModel::StrictValidationFailed: Name can't be blank
+</ruby>
+
h3. Conditional Validation
Sometimes it will make sense to validate an object just when a given predicate is satisfied. You can do that by using the +:if+ and +:unless+ options, which can take a symbol, a string or a +Proc+. You may use the +:if+ option when you want to specify when the validation *should* happen. If you want to specify when the validation *should not* happen, then you may use the +:unless+ option.
diff --git a/railties/guides/source/caching_with_rails.textile b/railties/guides/source/caching_with_rails.textile
index 6419d32c13..e2c6c7a2a4 100644
--- a/railties/guides/source/caching_with_rails.textile
+++ b/railties/guides/source/caching_with_rails.textile
@@ -359,7 +359,7 @@ h4. ActiveSupport::Cache::NullStore
This cache store implementation is meant to be used only in development or test environments and it never stores anything. This can be very useful in development when you have code that interacts directly with +Rails.cache+, but caching may interfere with being able to see the results of code changes. With this cache store, all +fetch+ and +read+ operations will result in a miss.
<ruby>
-ActionController::Base.cache_store = :null
+ActionController::Base.cache_store = :null_store
</ruby>
h4. Custom Cache Stores
diff --git a/railties/guides/source/layouts_and_rendering.textile b/railties/guides/source/layouts_and_rendering.textile
index be352cfe3d..4b4f9f3745 100644
--- a/railties/guides/source/layouts_and_rendering.textile
+++ b/railties/guides/source/layouts_and_rendering.textile
@@ -359,7 +359,7 @@ class ProductsController < ApplicationController
end
</ruby>
-With this declaration, all of the methods within +ProductsController+ will use +app/views/layouts/inventory.html.erb+ for their layout.
+With this declaration, all of the views rendered by the products controller will use +app/views/layouts/inventory.html.erb+ as their layout.
To assign a specific layout for the entire application, use a +layout+ declaration in your +ApplicationController+ class:
diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile
index df2bd9d0c9..24e7d09a49 100644
--- a/railties/guides/source/routing.textile
+++ b/railties/guides/source/routing.textile
@@ -301,6 +301,12 @@ If you wanted to link to just a magazine, you could leave out the +Array+:
<%= link_to "Magazine details", @magazine %>
</erb>
+For other actions, you just need to insert the action name as the first element of the +Array+:
+
+<erb>
+<%= link_to "Edit Ad", [:edit, @magazine, @ad] %>
+</erb>
+
This allows you to treat instances of your models as URLs, and is a key advantage to using the resourceful style.
h4. Adding More RESTful Actions