Have a look at the following code from spree
def new
@stock_movement = stock_location.stock_movements.build
end
def create
@stock_movement = stock_location.stock_movements.build(stock_movement_params)
@stock_movement.save
flash[:success] = flash_message_for(@stock_movement, :successfully_created)
redirect_to admin_stock_location_stock_movements_path(stock_location)
end
Is it really necessary to build associated object in new
method
@stock_movement = stock_location.stock_movements.build
or below line is fine
@stock_movement = StockMovement.new
Please explain..