api: refactor api attribute declarations.
Replace the `method_attributes` and `hidden_attributes` methods with
`api_attributes`. `api_attributes` can be used as a class macro:
# include only the given attributes.
api_attributes :id, :created_at, :creator_name, ...
# include all default attributes plus the `creator_name` method.
api_attributes including: [:creator_name]
or as an instance method:
def api_attributes
[:id, :created_at, :creator_name, ...]
end
By default, all attributes are included except for IP addresses and
tsvector columns.
This commit is contained in:
@@ -9,6 +9,8 @@ class PostAppeal < ApplicationRecord
|
||||
before_validation :initialize_creator, :on => :create
|
||||
validates_uniqueness_of :creator_id, :scope => :post_id, :message => "have already appealed this post"
|
||||
|
||||
api_attributes including: [:is_resolved]
|
||||
|
||||
module SearchMethods
|
||||
def resolved
|
||||
joins(:post).where("posts.is_deleted = false and posts.is_flagged = false")
|
||||
@@ -64,8 +66,4 @@ class PostAppeal < ApplicationRecord
|
||||
def appeal_count_for_creator
|
||||
creator.post_appeals.recent.count
|
||||
end
|
||||
|
||||
def method_attributes
|
||||
super + [:is_resolved]
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user