In my search controller I'm using a json render call for site search. I now need to pass a custom instance method to a JS file. The problem is, when I try to comma separate the necessary method (to_json
) I'm getting this error in my console:
SyntaxError (/game_app/app/controllers/search_controller.rb:13: syntax error, unexpected '}', expecting =>):
app/controllers/search_controller.rb:13: syntax error, unexpected '}', expecting =>
Controller Code
def autocomplete
render json: Game.search(params[:query], fields: [{ title: :word_start }], limit: 10), Game.to_json(methods: [:box_art_url])
end
Model Code
class Game < ActiveRecord::Base
def box_art_url
box_art.url(:thumb)
end
end