控制器文件中的rails3出错

时间:2011-10-05 10:57:25

标签: ruby-on-rails-3

这是控制器中的代码,我收到错误请帮助我

class HomeController < ApplicationController
  respond_to :json

  def index
    @home = Home.all

    respond_with(@home)

    cookies['AFID'] = {
      :value => request.env['AFID'],
      :expires => 1.year.from_now
    }


    cookies['SID'] = {
      :value => request.env['SID'],
      :expires => 1.year.from_now
    }

    #cookies[:AFID] = { :value =>}

  end


  def create
    @homes = Home.create(params[:home])

    respond_with(@home, :location => users_url)
  end
end

我收到了以下错误消息 HomeController中的NameError #index

1 个答案:

答案 0 :(得分:0)

首先,请使用代码缩进的Ruby约定!

如何将: value => request.env['AFID'],修改为:value => request.env['AFID'],?这有帮助吗?