0
다음 컨트롤러 Foobar
리소스를 갖는리소스 컨트롤러`# create` 메소드에서 인스턴스 변수를 설정해야합니까?
class FoobarController < ApplicationController
def new
@foobar = Foobar.new(baz: params[:baz])
@foobar.build_data
end
def create
@foobar = Foobar.new(foobar_params)
respond_with(@foobar)
end
# ...
end
그것은 #create
방법 가변 인스턴스 @foobar
을 설정할 필요가있다? 쓸 수 없습니까?
def create
Foobar.new(foobar_params).tap &method(:respond_with)
end
?