There is the following code for routing:
resources :orders, only: [:create], defaults: { format: \'json\' }
resources :users, only: [:create, :update],
I'd rather add method to application_controller. And use it as before filter where I want.
class ApplicationController < ActionController::Base
...
private
...
def set_default_format
params[:format] ||= "json"
end
end
class UsersController < ApplicationController
before_filter :set_default_format, only: [:create]
...
end
In this case default format wouldn't a surprise for new developers, because usually routes.rb is big and cumbersome