2013-12-08 46 views
0

一切似乎都在正确的地方,但显然不是。这里有一个要点在gists描述中的错误信息。找不到ID的工作室

https://gist.github.com/JRizzle88/7862465

编辑:

下面是跟踪开头:

Started GET "/studios/new" for 127.0.0.1 at 2013-12-08 13:52:41 -0600 
Processing by StudiosController#new as HTML 
Completed 404 Not Found in 1ms 

ActiveRecord::RecordNotFound - Couldn't find Studio without an ID: 
.... 
.... 
+1

你试图找到什么路径? –

+0

您的routes.rb,可能是相关的,也缺少要点。 –

+0

new_studio_path,因为我在使用资源产品指数 – jriley88

回答

1

更改您的before_filter在StudiosController到

before_action :set_studio, except: [:index, :new, :create] 

改变你的表演动作来

def show 
end 

更改您的新的动作,

def new 
    @studio = Studio.new 
end 
+0

我只是把@studio = Studio.new在我的高清指数products_controller和同样的错误 – jriley88

+1

我的坏 - 你不完全需要@studio。只需使用'new_studio_path'。 – janfoeh

+0

我将new_studio_path(@studio)更改为new_studio_path并且仍然一样:( – jriley88

1

before_action :set_studio 
在StudiosController

params[:id]似乎是nil在这里,它不能找到工作室与nil ID。您可能应该在之前的操作中添加onlyexcept参数。

另一个奇怪的是

@studio = Studio.new(params[:id]) 
在StudiosController#新

。它应该只是

@studio = Studio.new 

不是吗?

+0

我只是把[:new]添加到了我的before_action中并删除了(params [ :id])和仍然是相同的错误,我有(params [:id])那里只是尝试不同的事情,但来到了一个死胡同的事情来尝试,为什么我在这里大声笑 – jriley88

+1

不,你应该更换前的行动 'before_action:set_studio,除外:[:index,:new,:create]' 或 'before_action:set_studio,only:[:show,:edit,:update,:destroy]' –

+0

@ janfoeh的更新答案包含这些修复程序,请查看。 –

相关问题