Skip to content

Commit

Permalink
Fix bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Jul 19, 2012
1 parent 526585b commit acd7fda
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ class API < Grape::API
# Example
# /api/topics/1.json
get ":id" do
@topic = Topic.includes(:reply).find_by_id(params[:id])
@topic = Topic.includes(:replies).find_by_id(params[:id])
# TODO: this code can not run in Mongoid 3.0.1 issue https://github.com/mongoid/mongoid/issues/2204
# @topic = Topic.includes(:replies => [:user]).find_by_id(params[:id])
present @topic, :with => APIEntities::Topic
end

# Post a new reply
# require authentication
# params:
# params:
# body
# Example
# /api/topics/1/replies.json
Expand All @@ -74,7 +74,7 @@ class API < Grape::API
@reply.user_id = current_user.id
@reply.save
end

# Follow a topic
# require authentication
# params:
Expand All @@ -86,7 +86,7 @@ class API < Grape::API
@topic = Topic.find(params[:id])
@topic.push_follower(current_user.id)
end

# Unfollow a topic
# require authentication
# params:
Expand All @@ -98,13 +98,13 @@ class API < Grape::API
@topic = Topic.find(params[:id])
@topic.pull_follower(current_user.id)
end

# Add/Remove a topic to/from favorite
# require authentication
# params:
# params:
# type(optional) default is empty, set it unfavoritate to remove favorite
# Example
# /api/topics/1/favorite.json
# /api/topics/1/favorite.json
post ":id/favorite" do
authenticate!
if params[:type] == "unfavorite"
Expand Down

0 comments on commit acd7fda

Please sign in to comment.