0

我不断收到“NoMethodError at /dataset_requests/create undefined method `session' for #”。DatasetRequest 是一个模型,而不是控制器。该问题是由闪存和重定向方法引起的。可能是什么问题?

我的控制器:

Ims.controllers :dataset_requests do

  get :index do
    @requests = DatasetRequest.all(:account_id => current_account.id, :order => [:date_requested.desc])
    render 'dataset_requests/index'
  end

  post :create do
    @request = DatasetRequest.new(params[:dataset_request])
    @request.account_id = current_account.id
    @request.date_requested = DateTime.now

    if @request.save
      flash[:notice] = 'Request was successfully created.'
      redirect url(:dataset_requests, :index)
    else
      flash[:error] = 'Request could not be created.'
      render 'dataset_requests/index'
    end
  end

end
4

1 回答 1

0

现在我知道我犯的错误了。这是命名冲突。永远不要将你的 var 命名为“@request”。

于 2012-12-04T17:29:15.580 回答