This file contains hidden or 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
module UserDecorator | |
def short_name | |
name[0, 5] | |
end | |
# 以下のメソッドはUserモデルにもある。この状態でView側でcreated_atを使おうとすると | |
# SystemStackErrorが発生する | |
def created_at | |
created_at.strftime("%Y-%m-%d %H:%M") | |
end | |
end |
This file contains hidden or 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
<p id="notice"><%= notice %></p> | |
<p> | |
<strong>Name:</strong> | |
<%= @user.name %>(<%= @user.short_name %>) | |
</p> | |
<p> | |
<strong>Age:</strong> | |
<%= @user.age %> |
This file contains hidden or 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
<h1>Listing users</h1> | |
<table> | |
<thead> | |
<tr> | |
<th>Name</th> | |
<th>Age</th> | |
<th>Description</th> | |
<th colspan="3"></th> | |
</tr> |
This file contains hidden or 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
<p id="notice"><%= notice %></p> | |
<p> | |
<strong>Name:</strong> | |
<%= @user.name %>(<%= @user.short_name %>) | |
</p> | |
<p> | |
<strong>Age:</strong> | |
<%= @user.age %> |
This file contains hidden or 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
<h1>Listing users</h1> | |
<table> | |
<thead> | |
<tr> | |
<th>Name</th> | |
<th>Age</th> | |
<th colspan="3"></th> | |
</tr> | |
</thead> |
This file contains hidden or 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
module UserDecorator | |
def short_name | |
name[0, 5] | |
end | |
end |
This file contains hidden or 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
module UserDecorator | |
end |
This file contains hidden or 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
class UserDecorator < Draper::Decorator | |
delegate_all | |
decorates_finders | |
def short_name | |
object.name[0, 5] | |
end | |
end |
This file contains hidden or 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
Draper::CollectionDecorator.delegate :current_page, :total_pages, :limit_value, :total_count |
This file contains hidden or 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
def show | |
@user = UserDecorator.find(params[:id]) | |
end |
NewerOlder