1

I am getting the following error in Rails 3.2.9:

Template is missing

Missing template projects/create, application/create with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "c:/Documents and Settings/.../app/views"

I started getting this error yesterday, went back and rebuilt my controller and was still getting the error. I then rebuilt everything with the rails generate scaffold on the command line. When I went in to save a new object instance, I am still getting the same error.

My presumption is that the scaffold generator would produce the correct code on a bare-bones basis, and then allow me to piece by piece, rebuild the functionality.

I am including the code for the model and controller below:

class Project < ActiveRecord::Base
  attr_accessible   :title, ...

end

++++++++++

class ProjectsController < ApplicationController

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


  end

  # GET /projects/1
  def show
    @project = Project.find(params[:id])


  end

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


  end

  # GET /projects/1/edit
  def edit
    @project = Project.find(params[:id])
  end

  # POST /projects
  def create
    @project = Project.new(params[:project])
    @project.save

  end

  # PUT /projects/1
  def update
    @project = Project.find(params[:id])


  end

  # DELETE /projects/1
  def destroy
    @project = Project.find(params[:id])
    @project.destroy


  end
end

Anyone have any ideas? Did Rails develop a bug overnight? I haven't been able to find anything using Google-Fu that might attribute to this. Thanks.

4

1 に答える 1

2

Not sure about default rails scaffolding in rails but in general you should redirect on create with a success flash message:

@project = Project.new(params[:project])
if @project.save
  redirect_to @project, notice: "Success"
else
  render :new
end
于 2013-02-01T23:01:40.917 に答える