to_json should be as_json or there's bugs (#870)

* to_json should be as_json or there's bugs

* revert explore controller, it's better without

* revert search controller and some topic methods
This commit is contained in:
Devin Howard 2016-10-29 18:28:29 +08:00 committed by GitHub
parent 6cc827d11c
commit a32f98bde2
2 changed files with 6 additions and 6 deletions

View file

@ -83,7 +83,7 @@ class MapsController < ApplicationController
# GET maps/:id/contains # GET maps/:id/contains
def contains def contains
respond_to do |format| respond_to do |format|
format.json { render json: @map.contains(current_user).to_json(user: current_user) } format.json { render json: @map.contains(current_user).as_json(user: current_user) }
end end
end end

View file

@ -39,7 +39,7 @@ class TopicsController < ApplicationController
respond_with(@allsynapses, @alltopics, @allcreators, @topic) respond_with(@allsynapses, @alltopics, @allcreators, @topic)
end end
format.json { render json: @topic.to_json(user: current_user) } format.json { render json: @topic.as_json(user: current_user).to_json }
end end
end end
@ -55,9 +55,9 @@ class TopicsController < ApplicationController
@allcreators += @allsynapses.map(&:user).uniq @allcreators += @allsynapses.map(&:user).uniq
@json = {} @json = {}
@json['topic'] = @topic.to_json(user: current_user) @json['topic'] = @topic.as_json(user: current_user)
@json['creators'] = @allcreators @json['creators'] = @allcreators
@json['relatives'] = @alltopics.to_json(user: current_user) @json['relatives'] = @alltopics.as_json(user: current_user)
@json['synapses'] = @allsynapses @json['synapses'] = @allsynapses
respond_to do |format| respond_to do |format|
@ -114,7 +114,7 @@ class TopicsController < ApplicationController
end end
@json = {} @json = {}
@json['topics'] = alltopics.to_json(user: current_user) @json['topics'] = alltopics.as_json(user: current_user)
@json['synapses'] = allsynapses @json['synapses'] = allsynapses
@json['creators'] = allcreators @json['creators'] = allcreators
@ -131,7 +131,7 @@ class TopicsController < ApplicationController
respond_to do |format| respond_to do |format|
if @topic.save if @topic.save
format.json { render json: @topic.to_json(user: current_user), status: :created } format.json { render json: @topic.as_json(user: current_user), status: :created }
else else
format.json { render json: @topic.errors, status: :unprocessable_entity } format.json { render json: @topic.errors, status: :unprocessable_entity }
end end