Having resource Foobar with the following controller:
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
Is it necessary to set instance variable @foobar in #create method? Could not I just write
def create
Foobar.new(foobar_params).tap &method(:respond_with)
end
?