ruby-on-rails - 未定义的方法 `ceo_name=' for #
问题描述
说“我想将我的数据保存在数据库中,但是两个控制器都发生了一个错误。
这是我的控制器代码.....
class ChiefexecutiveofficerController < ApplicationController
def new
end
def index
@chiefexecutiveofficer = Chiefexecutiveofficer.all
end
def create
@chiefexecutiveofficer = Chiefexecutiveofficer.new()
@chiefexecutiveofficer.ceo_name = params[:chiefexecutiveofficer][:ceo_name]
@chiefexecutiveofficer.ceo_pin = params[:chiefexecutiveofficer][:ceo_pin]
@chiefexecutiveofficer.ceo_address = params[:chiefexecutiveofficer][:ceo_address]
@chiefexecutiveofficer.ceo_salary = params[:chiefexecutiveofficer][:ceo_salary]
if @chiefexecutiveofficer.save
flash[:notice]= " Your CEO Record Is Successfully Created"
redirect_to welcome_index_path
else
flash[:notice]= " Your CEO record Is Not Created"
redirect_to welcome_index_path
end
end
private
def my_params
params.require(:chiefexecutiveofficer).permit(:ceo_name,:ceo_name,:ceo_address,:ceo_salary)
end
end
解决方案
推荐阅读
- python - 如何在keras中向LSTM输入几个时间序列
- wordpress - 更改标签固定链接结构
- python - 第一个文件路径值未添加到 linux ubuntu 上的数组中
- autosar - uart 如何在 autosar 的 lin 模块中实现,或者如何将 LIN 配置为 uart ..?
- ruby - Dir.glob 卡住并且线程不移动
- java - 使用复杂的比较驱动流口水规则以从具有集合的对象中提取结果
- perforce - perforce中客户端和工作区之间的关系是什么?
- scala - 扩展空特征时使用类型参数的目的是什么?
- python - 在 Python 中的嵌套 Json 中搜索键
- javascript - 本地主机返回“未定义”而不是唯一 ID