意见/车辆/_form.html.haml
= link_to "Deactivate", "/vehicles/deactivate"
我想在上面的 link_to 中传递@vehicle。我该怎么做呢?
控制器/vehicles_controller.rb
def deactivate
@vehicle = Vehicle.find(params[:id])
@vehicle.active = 0
@vehicle.save
respond_to do |format|
format.html { redirect_to vehicles_url }
format.json { head :no_content }
end
end