неопределенный метод `ceo_name = 'для # <идентификатор Chiefexecutiveofficer: nil> - PullRequest
0 голосов
/ 24 апреля 2019

Скажите "Я хочу сохранить свои данные в базе данных, но в обоих контроллерах происходит одна ошибка.

Это мой код контроллера .....

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
...