bploetz / versionist

A plugin for versioning Rails based RESTful APIs.
MIT License
971 stars 51 forks source link

api_version should accept :defaults hash #5

Closed maletor closed 12 years ago

maletor commented 12 years ago
api_version(:module => "Api::V1", :path => "api/v1", :defaults => { :format => :json })

would be nice.

bploetz commented 12 years ago

Could you elaborate on what effect this defaults hash would have?

maletor commented 12 years ago

Sure.

Rails allows default params to be passed in to routes. Format is a param you can set too. This would mimic that behavior so that /users returns JSON instead of the first responder in responds_to block if no format specified or HTML if neither specified.

On Apr 16, 2012, at 8:26 PM, Brian Ploetz reply@reply.github.com wrote:

Could you elaborate on what effect this defaults hash would have?


Reply to this email directly or view it on GitHub: https://github.com/bploetz/versionist/issues/5#issuecomment-5167652

bploetz commented 12 years ago

Ah, gotcha. Will add this in 0.2.0.

maletor commented 12 years ago

I leave up to you to decide if you want to include in versionist. For now I have added this scope within api_version block.

scope :defaults => { :format => :json } do
bploetz commented 12 years ago

This is now available on the release-0.2.0 branch if you want to play around with it, and will be in the next release of versionist (0.2.0).

bploetz commented 12 years ago

Released in versionist 0.2.0

maletor commented 12 years ago

:+1: looks great.