I have a little REST-controller named password_resets, it has only create, show and update methods.
In routes.rb:
resources :password_resets, :only => [:create, :show, :update]
and I want one of the actions can manipulate with json by default, but others not. For all actions I can do:
scope :defaults => {format: 'json'} do
resources :password_resets, :only => [:create, :show, :update]
end
but how to do the same only for one action?
you can use multiple lines to setup differents formats:
resources :password_resets, :only => [:create, :update]
resources :password_resets, :only => [:show], :defaults => { :format => 'json' }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.