首页 > 解决方案 > Ruby on Rails - 参数丢失或值为空

问题描述

我正在为我的 rails 应用程序寻求帮助:

当我尝试在控制器下方的基于地标上创建估计时出现错误

def create
  @landmark = Landmark.find(params[:landmark_id])
  @estimate = Estimate.new(estimate_params)
  @estimate.landmark = @landmark
  @estimate.price = @landmark.price
  if @estimate.save
    # Deliver the signup email
    NotificationMailer.create_project(@estimate).deliver
    redirect_to landmark_path(@landmark, :notice => 'Booking created')
  else
    redirect_to landmark_path(@landmark, :notice => 'Error during creation')
  end
end

用我的参数:

def estimate_params
  params.require(:estimate).permit(:price)
end

我不明白为什么我的参数价格丢失了。

参数丢失或值为空:估计

预先感谢您的帮助

标签: ruby-on-rails

解决方案


推荐阅读