Use only new hash syntax

This commit is contained in:
Artem Chernikov 2014-07-21 14:49:05 +02:00
parent 3901973fd6
commit 5289f41eb5
72 changed files with 179 additions and 181 deletions

View file

@ -1,5 +1,5 @@
class Comment < ActiveRecord::Base
acts_as_nested_set :scope => [:commentable_id, :commentable_type]
acts_as_nested_set scope: [:commentable_id, :commentable_type]
attr_accessible :commentable, :body, :user_id
validates_presence_of :body
validates_presence_of :user
@ -8,7 +8,7 @@ class Comment < ActiveRecord::Base
# want user to vote on the quality of comments.
#acts_as_votable
belongs_to :commentable, :polymorphic => true
belongs_to :commentable, polymorphic: true
# NOTE: Comments belong to a user
belongs_to :user
@ -18,9 +18,9 @@ class Comment < ActiveRecord::Base
# example in readme
def self.build_from(obj, user_id, comment)
new \
:commentable => obj,
:body => comment,
:user_id => user_id
commentable: obj,
body: comment,
user_id: user_id
end
#helper method to check if a comment has children
@ -31,13 +31,13 @@ class Comment < ActiveRecord::Base
# Helper class method to lookup all comments assigned
# to all commentable types for a given user.
scope :find_comments_by_user, lambda { |user|
where(:user_id => user.id).order('created_at DESC')
where(user_id: user.id).order('created_at DESC')
}
# Helper class method to look up all comments for
# commentable class name and commentable id.
scope :find_comments_for_commentable, lambda { |commentable_str, commentable_id|
where(:commentable_type => commentable_str.to_s, :commentable_id => commentable_id).order('created_at DESC')
where(commentable_type: commentable_str.to_s, commentable_id: commentable_id).order('created_at DESC')
}
# Helper class method to look up a commentable object