-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
thin story serialzer and list out recent stories on the projects
- Loading branch information
1 parent
df37dd5
commit c42188e
Showing
4 changed files
with
15 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
class ProjectSerializer < ActiveModel::Serializer | ||
attributes :id, :name, :slug, :owner_id, :created_at, :updated_at, :deleted_at, :team_id | ||
has_many :users | ||
has_many :users, serializer: UserSerializer | ||
has_many :stories, serializer: ThinStorySerializer | ||
|
||
def stories | ||
object.stories.order(updated_at: :desc).take(5) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class ThinStorySerializer < ActiveModel::Serializer | ||
attributes :id, :name, :slug, :updated_at | ||
end |