我在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"
我昨天开始出现这个错误,回去重建了我的控制器,但仍然出现错误。然后,我在命令行中使用rails generate scaffold
重建了所有内容。当我去保存一个新的对象实例时,我仍然会得到同样的错误。
我的假设是,scaffold生成器将在基本的基础上生成正确的代码,然后允许我逐个重建功能。
我包括下面的模型和控制器的代码:
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
有人有什么想法吗?Rails是不是一夜之间就开发出了一个bug?我在谷歌上找不到任何可能归因于此的东西。谢谢
不确定rails中的默认rails脚手架,但通常情况下,您应该在创建时重定向一条成功的flash消息:
@project = Project.new(params[:project])
if @project.save
redirect_to @project, notice: "Success"
else
render :new
end