-1

我的漂亮发电机控制器遇到了一些与块相关的问题。我对rails很陌生,所以毫无疑问这是一个简单的问题。这是我的错误:

/home/forrest/.rvm/gems/ruby-1.9.2-p320@global/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `require': /home/forrest/code/ luxeldb/app/models/maintenance_record.rb:16:语法错误,意外 $end,期待关键字_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
4

1 回答 1

3

直接从错误消息中读取,语法错误在您的/home/forrest/code/luxeldb/app/models/maintenance_record.rb文件中,而不是控制器中。

您错过了一个end关键字,Ruby 发现了这个关键字,因为它在$end等待结束关键字时到达了文件的末尾 ( )

于 2012-08-19T02:17:53.703 回答