Permalink
Browse files

Use request.format instead of params[:format]

This works even in case the format is not explicitly specified (i.e. Backbone.js does not send a format parameter when fetching data)
  • Loading branch information...
1 parent ae21d67 commit 6203914b81190d30e08b874c151d9d2b3842d7ae @dbloete dbloete committed Nov 5, 2011
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/api_builder/renderer.rb
@@ -75,7 +75,8 @@ def element(name, value = nil, &block)
end
def get_output
- case params[:format].to_sym
+ format = request.format.to_sym
+ case format
when :json
if params[:callback]
"#{params[:callback]}(#{@_out.to_json})"
@@ -85,7 +86,7 @@ def get_output
when :xml
@_out.to_xml
else
- raise "unknown format '#{params[:format]}'"
+ raise ArgumentError, "unknown format '#{format}'"
end
end
end

0 comments on commit 6203914

Please sign in to comment.