提交 500ca98f 编写于 作者: V Vijay Dev

Merge branch 'master' of github.com:lifo/docrails

......@@ -12,7 +12,7 @@ module Default
end
module ClassMethods
# Returns a scope for this class without taking into account the default_scope.
# Returns a scope for the model without the default_scope.
#
# class Post < ActiveRecord::Base
# def self.default_scope
......@@ -23,18 +23,20 @@ module ClassMethods
# Post.all # Fires "SELECT * FROM posts WHERE published = true"
# Post.unscoped.all # Fires "SELECT * FROM posts"
#
# This method also accepts a block meaning that all queries inside the block will
# This method also accepts a block. All queries inside the block will
# not use the default_scope:
#
# Post.unscoped {
# Post.limit(10) # Fires "SELECT * FROM posts LIMIT 10"
# }
#
# It is recommended to use block form of unscoped because chaining unscoped with <tt>scope</tt>
# does not work. Assuming that <tt>published</tt> is a <tt>scope</tt> following two statements are same.
# It is recommended to use the block form of unscoped because chaining
# unscoped with <tt>scope</tt> does not work. Assuming that
# <tt>published</tt> is a <tt>scope</tt>, the following two statements
# are equal: the default_scope is applied on both.
#
# Post.unscoped.published
# Post.published
# Post.unscoped.published
# Post.published
def unscoped #:nodoc:
block_given? ? relation.scoping { yield } : relation
end
......
......@@ -87,7 +87,7 @@ def assert_blank(object, message=nil)
# Test if an expression is not blank. Passes if object.present? is true.
#
# assert_present {:data => 'x' } # => true
# assert_present({:data => 'x' }) # => true
def assert_present(object, message=nil)
message ||= "#{object.inspect} is blank"
assert object.present?, message
......
module RailsGuides
module Levenshtein
# Based on the pseudocode in http://en.wikipedia.org/wiki/Levenshtein_distance.
# Based on the pseudocode in http://en.wikipedia.org/wiki/Levenshtein_distance
def self.distance(s1, s2)
s = s1.unpack('U*')
t = s2.unpack('U*')
......
......@@ -41,9 +41,6 @@ internet for learning Ruby, including:
* "Programming Ruby":http://www.ruby-doc.org/docs/ProgrammingRuby/
* "Why's (Poignant) Guide to Ruby":http://mislav.uniqpath.com/poignant-guide/
Also, the example code for this guide is available in the rails github:https://github.com/rails/rails repository
in rails/railties/guides/code/getting_started.
h3. What is Rails?
TIP: This section goes into the background and philosophy of the Rails framework
......
......@@ -814,7 +814,7 @@ replaying the entire migration history. It is much simpler and faster to just
load into the database a description of the current schema.
For example, this is how the test database is created: the current development
database is dumped (either to +db/schema.rb+ or +db/development.sql+) and then
database is dumped (either to +db/schema.rb+ or +db/structure.sql+) and then
loaded into the test database.
Schema files are also useful if you want a quick look at what attributes an
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册