开发者

Implementing REST-api with different defaults format

I have a little REST-controller named password_resets, it has o开发者_开发技巧nly 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' }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜