Archive for November, 2011

Responding with the contents of a JSON file in Rails

No Comments »

I have a schedule.json file that I want to dump to the browser for testing purposes.

This took entirely too long for me to sort out through trial and error, but here it is:

#/app/controllers/some_controller.rb
def schedule
    render :file => "#{Rails.root}/app/assets/resources/analytics/schedule.json",
      :content_type => 'application/json',
      :layout => false
end