Reputation: 13852
For some reason,
render json: User.all
with a caches_action for :index returns content type text/html. How do I force it to application/json?
Before:
def index
render json: User.all.to_json
end
Returns json with Content-Type: 'application/json'
After:
caches_action :index
def index
render json: User.all.to_json
end
Returns json with Content-Type: 'text/html'. So technically it's a json string in html.
Upvotes: 1
Views: 97
Reputation: 1931
The safest way to do that, according to the documentation is to declare your route as a json route in your config/routes.rb
Upvotes: 1