Browse files

print name with summary at users#man

  • Loading branch information...
1 parent 23310b1 commit 77b0c4481cf8b81c7456d875eb8397fe18ff52b7 @naoty committed Jul 27, 2012
Showing with 17 additions and 1 deletion.
  1. +7 −0 app/helpers/application_helper.rb
  2. +7 −0 app/models/user.rb
  3. +2 −0 app/views/users/man.text.erb
  4. +1 −1 config/routes.rb
View
7 app/helpers/application_helper.rb
@@ -1,2 +1,9 @@
module ApplicationHelper
+
+ INDENT = ' '
+
+ def indent(text, n = 1)
+ text.prepend(INDENT * n)
+ end
+
end
View
7 app/models/user.rb
@@ -6,6 +6,8 @@ class User
RESERVED_NAMES = ['users', 'signup']
field :name
+ field :summary
+ field :description
field :encrypted_password
field :salt
@@ -45,6 +47,11 @@ def items
attributes.reject {|field| UNLISTED_ITEMS.include?(field) }
end
+ def name_with_summary
+ self.name += " -- #{summary}" if summary.present?
+ self.name
+ end
+
private
def encrypt_password
View
2 app/views/users/man.text.erb
@@ -0,0 +1,2 @@
+<%= 'NAME'.bold %>
+<%= indent @user.name_with_summary %>
View
2 config/routes.rb
@@ -2,8 +2,8 @@
scope '/', defaults: { format: :text } do
get 'users' => 'users#index'
get ':id' => 'users#show'
- get ':id/:item' => 'users#item'
get ':id/man' => 'users#man'
+ get ':id/:item' => 'users#item'
post 'signup' => 'users#create'
put ':id' => 'users#update'
delete ':id' => 'users#destroy'

0 comments on commit 77b0c44

Please sign in to comment.