diff options
Diffstat (limited to 'activerecord/lib/active_record/relation')
5 files changed, 15 insertions, 15 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index f02ed62275..c8edadf804 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -145,7 +145,7 @@ module ActiveRecord # # SELECT DISTINCT role FROM people # # => ['admin', 'member', 'guest'] # - # Person.where(:age => 21).limit(5).pluck(:id) + # Person.where(age: 21).limit(5).pluck(:id) # # SELECT people.id FROM people WHERE people.age = 21 LIMIT 5 # # => [2, 3] # diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index af67b2ba6c..eafe4a54c4 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -76,7 +76,7 @@ module ActiveRecord # # Person.first # returns the first object fetched by SELECT * FROM people # Person.where(["user_name = ?", user_name]).first - # Person.where(["user_name = :u", { :u => user_name }]).first + # Person.where(["user_name = :u", { u: user_name }]).first # Person.order("created_on DESC").offset(5).first # Person.first(3) # returns the first three objects fetched by SELECT * FROM people LIMIT 3 def first(limit = nil) diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb index bd7aeb0c4e..83074e72c1 100644 --- a/activerecord/lib/active_record/relation/predicate_builder.rb +++ b/activerecord/lib/active_record/relation/predicate_builder.rb @@ -36,10 +36,10 @@ module ActiveRecord queries = [] # Find the foreign key when using queries such as: - # Post.where(:author => author) + # Post.where(author: author) # # For polymorphic relationships, find the foreign key and type: - # PriceEstimate.where(:estimate_of => treasure) + # PriceEstimate.where(estimate_of: treasure) if klass && value.class < Base && reflection = klass.reflect_on_association(column.to_sym) if reflection.polymorphic? queries << build(table[reflection.foreign_type], value.class.base_class) diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 0817bb6d81..b3712b4ad6 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -355,17 +355,17 @@ module ActiveRecord # author = Author.find(1) # # # The following queries will be equivalent: - # Post.where(:author => author) - # Post.where(:author_id => author) + # Post.where(author: author) + # Post.where(author_id: author) # # This also works with polymorphic belongs_to relationships: # - # treasure = Treasure.create(:name => 'gold coins') - # treasure.price_estimates << PriceEstimate.create(:price => 125) + # treasure = Treasure.create(name: 'gold coins') + # treasure.price_estimates << PriceEstimate.create(price: 125) # # # The following queries will be equivalent: - # PriceEstimate.where(:estimate_of => treasure) - # PriceEstimate.where(:estimate_of_type => 'Treasure', :estimate_of_id => treasure) + # PriceEstimate.where(estimate_of: treasure) + # PriceEstimate.where(estimate_of_type: 'Treasure', estimate_of_id: treasure) # # === Joins # @@ -377,7 +377,7 @@ module ActiveRecord # For hash conditions, you can either use the table name in the key, or use a sub-hash. # # User.joins(:posts).where({ "posts.published" => true }) - # User.joins(:posts).where({ :posts => { :published => true } }) + # User.joins(:posts).where({ posts: { published: true } }) # # === empty condition # @@ -476,13 +476,13 @@ module ActiveRecord # # For example: # - # @posts = current_user.visible_posts.where(:name => params[:name]) + # @posts = current_user.visible_posts.where(name: params[:name]) # # => the visible_posts method is expected to return a chainable Relation # # def visible_posts # case role # when 'Country Manager' - # Post.where(:country => country) + # Post.where(country: country) # when 'Reviewer' # Post.published # when 'Bad User' diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb index 5394c1b28b..62dda542ab 100644 --- a/activerecord/lib/active_record/relation/spawn_methods.rb +++ b/activerecord/lib/active_record/relation/spawn_methods.rb @@ -15,11 +15,11 @@ module ActiveRecord # # ==== Examples # - # Post.where(:published => true).joins(:comments).merge( Comment.where(:spam => false) ) + # Post.where(published: true).joins(:comments).merge( Comment.where(spam: false) ) # # Performs a single join query with both where conditions. # # recent_posts = Post.order('created_at DESC').first(5) - # Post.where(:published => true).merge(recent_posts) + # Post.where(published: true).merge(recent_posts) # # Returns the intersection of all published posts with the 5 most recently created posts. # # (This is just an example. You'd probably want to do this with a single query!) # |