to_json should be as_json or there's bugs

This commit is contained in:
Devin Howard 2016-10-29 11:27:25 +08:00
parent 6cc827d11c
commit 2b2017d059
4 changed files with 17 additions and 17 deletions

View file

@ -17,7 +17,7 @@ class ExploreController < ApplicationController
redirect_to(root_url) && return if authenticated?
respond_with(@maps, @user)
end
format.json { render json: @maps.to_json }
format.json { render json: @maps.as_json }
end
end
@ -27,7 +27,7 @@ class ExploreController < ApplicationController
respond_to do |format|
format.html { respond_with(@maps, @user) }
format.json { render json: @maps.to_json }
format.json { render json: @maps.as_json }
end
end
@ -37,7 +37,7 @@ class ExploreController < ApplicationController
respond_to do |format|
format.html { respond_with(@maps, @user) }
format.json { render json: @maps.to_json }
format.json { render json: @maps.as_json }
end
end
@ -47,7 +47,7 @@ class ExploreController < ApplicationController
respond_to do |format|
format.html { respond_with(@maps, @user) }
format.json { render json: @maps.to_json }
format.json { render json: @maps.as_json }
end
end
@ -57,7 +57,7 @@ class ExploreController < ApplicationController
respond_to do |format|
format.html { respond_with(@maps, @user) }
format.json { render json: @maps.to_json }
format.json { render json: @maps.as_json }
end
end
@ -68,7 +68,7 @@ class ExploreController < ApplicationController
respond_to do |format|
format.html { respond_with(@maps, @user) }
format.json { render json: @maps.to_json }
format.json { render json: @maps.as_json }
end
end

View file

@ -83,7 +83,7 @@ class MapsController < ApplicationController
# GET maps/:id/contains
def contains
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

View file

@ -73,7 +73,7 @@ class SearchController < ApplicationController
@topics = []
end
render json: autocomplete_array_json(@topics).to_json
render json: autocomplete_array_json(@topics).as_json
end
# get /search/maps?term=SOMETERM
@ -107,7 +107,7 @@ class SearchController < ApplicationController
@maps = []
end
render json: autocomplete_map_array_json(@maps).to_json
render json: autocomplete_map_array_json(@maps).as_json
end
# get /search/mappers?term=SOMETERM
@ -125,7 +125,7 @@ class SearchController < ApplicationController
else
@mappers = []
end
render json: autocomplete_user_array_json(@mappers).to_json
render json: autocomplete_user_array_json(@mappers).as_json
end
# get /search/synapses?term=SOMETERM OR
@ -151,7 +151,7 @@ class SearchController < ApplicationController
# limit to 5 results
@synapses = @synapses.to_a.slice(0, 5)
render json: autocomplete_synapse_array_json(@synapses).to_json
render json: autocomplete_synapse_array_json(@synapses).as_json
end
private

View file

@ -22,7 +22,7 @@ class TopicsController < ApplicationController
end
@all= @topics.to_a.concat(@maps.to_a).sort { |a, b| a.name <=> b.name }
render json: autocomplete_array_json(@all).to_json
render json: autocomplete_array_json(@all).as_json
end
# GET topics/:id
@ -39,7 +39,7 @@ class TopicsController < ApplicationController
respond_with(@allsynapses, @alltopics, @allcreators, @topic)
end
format.json { render json: @topic.to_json(user: current_user) }
format.json { render json: @topic.as_json(user: current_user) }
end
end
@ -55,9 +55,9 @@ class TopicsController < ApplicationController
@allcreators += @allsynapses.map(&:user).uniq
@json = {}
@json['topic'] = @topic.to_json(user: current_user)
@json['topic'] = @topic.as_json(user: current_user)
@json['creators'] = @allcreators
@json['relatives'] = @alltopics.to_json(user: current_user)
@json['relatives'] = @alltopics.as_json(user: current_user)
@json['synapses'] = @allsynapses
respond_to do |format|
@ -114,7 +114,7 @@ class TopicsController < ApplicationController
end
@json = {}
@json['topics'] = alltopics.to_json(user: current_user)
@json['topics'] = alltopics.as_json(user: current_user)
@json['synapses'] = allsynapses
@json['creators'] = allcreators
@ -131,7 +131,7 @@ class TopicsController < ApplicationController
respond_to do |format|
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
format.json { render json: @topic.errors, status: :unprocessable_entity }
end