ruby-on-rails - 阻止 f.range_field 提交数据,除非与
问题描述
我有以下 f.range_field 在控制器中调用我的更新方法:
= f.range_field :feeling, :in => 1..3, :step => '1'
控制器:
if @workout.update_attributes(workout_params)
redirect_to team_user_workouts_path(current_user.team,
current_user, athlete: params[:athlete])
else
render(:edit, athlete: params[:athlete])
end
我通常会使用 select_field include_blank: 'choose'
,这将确保如果未与选择字段交互 - 特定参数不会提交。如何使用范围字段实现相同的效果?现在,即使我不与它交互,它也会提交。
解决方案
推荐阅读
- oauth-2.0 - 如何在 oAuth 2.0 中存储和使用访问令牌和刷新令牌以保持用户的登录状态?(吉拉 OAuth 2.0)
- python - Pandas DataFrame 基于依赖于具有累积计数规则的其他列的逻辑创建新列
- android - Android:如何从相机获取原始图像数据
- node.js - 将 pdf 转换为图像不适用于 Windows 上的 Nodejs sharp
- single-sign-on - 当我们在 MS Edge 中启用 IE 模式时,ADFS SSO 失败
- bash - zsh 和 bashrc 命令未找到 ts-node
- apache-spark - 检查每个 RDD spark 内部的数据
- stm32 - 如何使用 HAL_I2C_Transmit?
- javascript - 如何将可点击对象添加到 AFRAME 中的模型数组
- amazon-web-services - 找不到 ecs-deploy 命令