Commit f34e9ad3a135ee8c05b9cab16c1bcde6df06851a

Authored by Leandro Santos
Committed by Rodrigo Souto
1 parent c42ac8b4

solving bug create comment with person not user

Showing 2 changed files with 5 additions and 1 deletions   Show diff stats
lib/api/helpers.rb
@@ -9,6 +9,10 @@ module API @@ -9,6 +9,10 @@ module API
9 @current_user 9 @current_user
10 end 10 end
11 11
  12 + def current_person
  13 + current_user.person unless current_user.nil?
  14 + end
  15 +
12 def logout 16 def logout
13 @current_user = nil 17 @current_user = nil
14 end 18 end
lib/api/v1/comments.rb
@@ -28,7 +28,7 @@ module API @@ -28,7 +28,7 @@ module API
28 # Example Request: 28 # Example Request:
29 # POST api/v1/articles/12/comments?private_toke=234298743290432&body=new comment 29 # POST api/v1/articles/12/comments?private_toke=234298743290432&body=new comment
30 post ":id/comments" do 30 post ":id/comments" do
31 - present environment.articles.find(params[:id]).comments.create(:author => current_user, :body => params[:body]), :with => Entities::Comment 31 + present environment.articles.find(params[:id]).comments.create(:author => current_person, :body => params[:body]), :with => Entities::Comment
32 end 32 end
33 end 33 end
34 34