dimanche 19 mars 2017

Error message: First argument in form cannot contain nil or be empty

I have aproblem with my Rails application. I'm getting the following error message for my project.start.html.erb: First argument in form can not contain nil or be empty ...

What can be the reason?

Here are my related files:

project.start:

<div class="row">
  <div class="span5">
    <h2>Programme</h2>
    <%= form_for (@project) do |f| %>
        <div class="field">
          <%= f.label :path, "GAMS-Verzeichnis" %>
          <%= f.text_field :path %>
          <a href="http://ift.tt/J755SN">(GAMS-Download)</a>
        </div>

        <br/>

        <div class="actions">
          <%= f.submit 'Verzeichnisse aktualisieren', :class => "btn"  %>
        </div>
    <% end %>
  </div>
</div>

projects.controller:

class ProjectsController < ApplicationController
  before_action :set_project, only: [:show, :edit, :update, :destroy]

  # GET /projects
  # GET /projects.json
  def index
    @projects = Project.all
  end

  # GET /projects/1
  # GET /projects/1.json
  def show
  end

  # GET /projects/new
  def new
    @project = Project.new
  end

  # GET /projects/1/edit
  def edit
  end

  # POST /projects
  # POST /projects.json
  def create
    @project = Project.new(project_params)

    respond_to do |format|
      if @project.save
        format.html { redirect_to @project }
        format.json { render :show, status: :created, location: @project }
      else
        format.html { render :new }
        format.json { render json: @project.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /projects/1
  # PATCH/PUT /projects/1.json
  def update
    respond_to do |format|
      if @project.update(project_params)
        format.html { redirect_to @project }
        format.json { render :show, status: :ok, location: @project }
      else
        format.html { render :edit }
        format.json { render json: @project.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /projects/1
  # DELETE /projects/1.json
  def destroy
    @project.destroy
    respond_to do |format|
      format.html { redirect_to projects_url }
      format.json { head :no_content }
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_project
      @project = Project.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def project_params
      params.require(:project).permit(:name, :deadline, :closed, :gvp, :path, :startdate, :zwt, :zwc, :totalc, :extrac)
    end
end

Tanks for the help! :)

Aucun commentaire:

Enregistrer un commentaire