respond_with について [ 自分用メモ ]
参考サイト
http://blog.livedoor.jp/sasata299/archives/51804693.html
http://d.hatena.ne.jp/shilen40/20130515/1368624103
例)
class UsersController < ApplicationController::Base
respond_to :html, :xml, :json
def index
respond_with(@users = User.all)
end
def create
@user = User.create(params[:user])
respond_with(@user, location: users_url)
end
end
・respond_toとペアで使って上のように書くことができる。
・respond_withメソッドを使うときは、respond_toメソッドとペアで使う必要がある。
・respond_toメソッドで指定していないフォーマットでアクセスされると、406 Not Acceptableエラーを返す。
Author And Source
この問題について(respond_with について [ 自分用メモ ]), 我々は、より多くの情報をここで見つけました https://qiita.com/dawn_628/items/19786b634dbb71f4819b著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .