2013-12-08 55 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的更新答案包含這些修復程序,請查看。 –

相關問題