Commit b406526ef9529d8b9ef722141c152fcceee38e1a

Authored by Victor Costa
Committed by Rodrigo Souto
1 parent 464426aa

Fix api date format

Showing 2 changed files with 11 additions and 5 deletions   Show diff stats
lib/api/entities.rb
1 1 module API
2 2 module Entities
3 3  
  4 + Grape::Entity.format_with :timestamp do |date|
  5 + date.strftime('%Y/%m/%d %H:%M:%S') if date
  6 + end
  7 +
4 8 class Image < Grape::Entity
5 9 root 'images', 'image'
6 10  
... ... @@ -22,7 +26,8 @@ module API
22 26 end
23 27  
24 28 class Profile < Grape::Entity
25   - expose :identifier, :name, :created_at, :id
  29 + expose :identifier, :name, :id
  30 + expose :created_at, :format_with => :timestamp
26 31 expose :image, :using => Image
27 32 end
28 33  
... ... @@ -42,7 +47,8 @@ module API
42 47  
43 48 class Article < Grape::Entity
44 49 root 'articles', 'article'
45   - expose :id, :body, :created_at
  50 + expose :id, :body
  51 + expose :created_at, :format_with => :timestamp
46 52 expose :title, :documentation => {:type => "String", :desc => "Title of the article"}
47 53 expose :author, :using => Profile
48 54 expose :profile, :using => Profile
... ... @@ -51,8 +57,8 @@ module API
51 57  
52 58 class Comment < Grape::Entity
53 59 root 'comments', 'comment'
54   - expose :body, :title, :created_at, :id
55   -
  60 + expose :body, :title, :id
  61 + expose :created_at, :format_with => :timestamp
56 62 expose :author, :using => Profile
57 63 end
58 64  
... ...
lib/api/helpers.rb
... ... @@ -169,7 +169,7 @@ module API
169 169 protected
170 170  
171 171 def start_log
172   - logger.info "Started #{request.path}"
  172 + logger.info "Started #{request.path} #{request.params.except('password')}"
173 173 end
174 174 def end_log
175 175 logger.info "Completed #{request.path}"
... ...