Simplify user action make it more idiomatic

This commit is contained in:
Sam
2013-05-27 10:22:37 +10:00
parent 6046d33645
commit d84ae80074
4 changed files with 70 additions and 36 deletions

View File

@@ -0,0 +1,27 @@
class UserActionSerializer < ApplicationSerializer
attributes :action_type, :created_at, :excerpt,
:avatar_template, :acting_avatar_template,
:slug, :topic_id, :target_user_id, :target_name,
:target_username, :post_number, :reply_to_post_number,
:username, :name, :user_id, :acting_username,
:acting_name, :acting_user_id
def excerpt
PrettyText.excerpt(object.cooked,300) if object.cooked
end
def avatar_template
User.avatar_template(object.email)
end
def acting_avatar_template
User.avatar_template(object.acting_email)
end
def slug
Slug.for(object.title)
end
end