查看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
是否真的有必要在new
方法
@stock_movement = stock_location.stock_movements.build
或以下行很好
@stock_movement = StockMovement.new
请解释..