Em 14-05-2012 02:11, Andrew White escreveu:
...
That shortcoming could be minimized if we assumed the "format: :json" to 
restrict the only possible format to 'json' instead of using it as a default.

Please consider this change to routing DSL for Rails 4.
We could certainly consider whether :format =>  :json or :format =>  [:html, 
:json] would restrict it to those formats (i.e. setup :constraints and :defaults 
automatically), however that would have to be with :format in the path as you can't turn 
it off without :format =>  false. Please open an issue to consider this further.

I've noticed an annoying issue while trying the js-routes gem. I have some routes like this:

scope format: true, constraints: {format: /json/} do
...
end

If we change the meaning of "format: :json" I'd be able to just call "some_path", instead of "some_path('json')".

I've even tried to add a defaults arguments ({defaults: :json}), but it seems the router is not smart enough for not requiring the format to be specified.

So, if I opt for using js-routes I'd need to write my routes as "sections_path('json')", while I'd prefer to just call "sections_path()".

Can you see how useful it could be to change the meaning of the format parameter when a non-boolean value is used?

Thanks for considering this change.

Cheers,
Rodrigo.

--
You received this message because you are subscribed to the Google Groups "Ruby on 
Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to