我的控制器由漂亮的发电机有一些块相关的问题。我对rails非常陌生,所以毫无疑问这是一个简单的问题。这是我的错误:
/home/forrest/.rvm/gems/ruby-1.9.2-p320@global/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in`requirement':/ home / forrest /code/luxeldb/app/models/maintenance_record.rb:16:语法错误,意外$ end,期待keyword_end(SyntaxError)
这是我的控制器:
class MaintenanceRecordsController < ApplicationController
def index
@maintenance_records = MaintenanceRecord.find(:all)
end
def show
@maintenance_record = MaintenanceRecord.find(params[:id])
end
def new
@maintenance_record = MaintenanceRecord.new
end
def create
@maintenance_record = MaintenanceRecord.new(params[:maintenance_record])
if @maintenance_record.save
redirect_to @maintenance_record, :notice => "Successfully created maintenance record."
else
render :action => 'new'
end
end
def edit
@maintenance_record = MaintenanceRecord.find(params[:id])
end
def update
@maintenance_record = MaintenanceRecord.find(params[:id])
if @maintenance_record.update_attributes(params[:maintenance_record])
redirect_to @maintenance_record, :notice => "Successfully updated maintenance record."
else
render :action => 'edit'
end
end
def destroy
@maintenance_record = MaintenanceRecord.find(params[:id])
@maintenance_record.destroy
redirect_to maintenance_records_url, :notice => "Successfully destroyed maintenance record."
end
end
答案 0 :(得分:3)
直接从错误消息中读取,语法错误位于/home/forrest/code/luxeldb/app/models/maintenance_record.rb
文件中,而不是控制器中。
你错过了一个end
关键字输出,Ruby发现它是因为它在等待结束关键字时到达文件末尾($end
)