无法更新数据库形式的数据

岩石

我收到错误-未定义的方法collect进行nil:NilClass,但我能够从另一个数据库表呈现选项列表,还可以将数据保存期表,但无法对其进行更新。我正在阶段表单字段职责选项中呈现选项列表表单职责表,并将该选项保存到阶段表中。

在此处输入图片说明

stage_controller.rb

  def index
    redirect_to project_path(@project)
  end

  def show
  end


  def new
    @stage = Stage.new
    @responsibilities = @project.responsibilities
  end

  def edit
  end

  def create
      @responsibilities = @project.responsibilities

    @stage = @project.stages.build(stage_params)

    respond_to do |format|
      if @stage.save
        format.html { redirect_to project_path(@project), notice: 'Stage was successfully created.' }
        format.json { render :show, status: :created, location: @stage }
      else
        format.html { render :new }
        format.json { render json: @stage.errors, status: :unprocessable_entity }
      end
    end
  end


  def update
    @responsibilities = @project.responsibilities

    respond_to do |format|
      if @stage.update(stage_params)
        format.html { redirect_to project_stages_url, notice: 'Stage was successfully updated.' }
        format.json { render :show, status: :ok, location: @stage }
      else
        format.html { render :edit }
        format.json { render json: @stage.errors, status: :unprocessable_entity }
      end
    end
  end

  def destroy
    @stage.destroy
    respond_to do |format|
      format.html { redirect_to project_stages_url, notice: 'Stage was successfully deleted.' }
      format.json { head :no_content }
    end
  end

  private
    def set_stage
      @stage = Stage.find(params[:id])
    end

    def find_project
      @project = Project.find(params[:project_id])
    end
维贾贾德

您的编辑方法为空,因此@responsibility不包含任何内容(空),例如,您可以放置​​一些代码(来自其他方法)

def edit
  @project = Project.find(params[:id])
  @responsibilities = @project.responsibilities
  ...
end

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

无法更新数据库

来自分类Dev

无法从MySQL数据库更新数据

来自分类Dev

PHP的形式不更新数据库

来自分类Dev

从引导模式形式更新数据库

来自分类Dev

以表格形式加载数据并更新数据库中的行

来自分类Dev

无法更新数据库中的对象

来自分类Dev

无法通过Laravel更新数据库

来自分类Dev

数据库无法连接或更新

来自分类Dev

实体框架无法更新数据库

来自分类Dev

我无法从python更新数据库

来自分类Dev

无法更新SQL数据库

来自分类Dev

无法更新数据库中的列

来自分类Dev

无法更新数据库中的行

来自分类Dev

无法更新数据库中的字段

来自分类Dev

无法更新我的数据库

来自分类Dev

无法更新数据库数据。拉拉韦尔

来自分类Dev

无法将数据更新到数据库

来自分类Dev

无法通过表单数据更新数据库

来自分类Dev

无法更新Kinvey数据库中的数据

来自分类Dev

Android - 我无法从 SQLite 数据库更新数据

来自分类Dev

从数据库中的表以不同的形式更新表

来自分类Dev

数据库不会使用php形式更新值

来自分类Dev

尝试更新php中的mysql数据库形式

来自分类Dev

Codeigniter更新记录-无法在数据库中更新

来自分类Dev

无法更新后数据库更新当前时间戳

来自分类Dev

如果数据库是只读的,则无法更新数据库

来自分类Dev

由于数据库是只读的,因此无法更新数据库

来自分类Dev

如果数据库是只读的,则无法更新数据库

来自分类Dev

我无法更新数据库。Symfony PHP数据库原则