我得到這個錯誤:走走在控制器未知行動「
「行動‘創造’無法找到ObjectController」
我知道這應該是顯而易見的,但我失去了一些東西,這是我的控制器:
class ObjectController < ApplicationController
def index
end
def create
end
end
這是我的路線:
Rails.application.routes.draw do
get 'object/index'
get 'object/create'
match ':controller(/:action(/:id))', :via => :get
resources :objets
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
root 'object#index'
這裏有一些奇怪的事情發生,但最明顯的是這裏的拼寫錯誤:'資源:objets'(應該是'resources:objects')。另外,按照慣例,您應該始終以複數形式命名您的控制器。即'ObjectsController'而不是'ObjectController'。然後使用下面的勘誤表。 – dwenzel
感謝您的回答,我發現了這個問題,但我會記住您的建議;) –
您需要指向'objects/index'(複數對象) –