0
我已經爲此搜索了高和低,其他解決方案似乎沒有幫助。 錯誤:無法找到WatchedWatchersController的操作'create'
The action 'create' could not be found for WatchedWatchersController
我得到這個點擊這個代碼在一個視圖中做了一個鏈接後:
<%= link_to 'Watchlist', { :controller => "watched_watchers",
:action => "create",
:watcher_id => current_user.id,
:watched_id => user.id},
:method => "post" %>
我對這個類模式是:
class Watched_Watcher < ActiveRecord::Base
attr_accessible :watched_id, :watcher_id
validates :watched_id, :watcher_id, presence: true
end
我的控制器是:
class WatchedWatchersController < ApplicationController
def new
end
def create
@ww = Watched_Watcher.new
@ww.watcher_id = params[:watcher_id]
@ww.watched_id = params[:watched_id]
@ww.save
end
def update
end
def edit
end
def destroy
end
def index
end
def show
end
end
我已經設置了我的路線爲REST資源:
resources :watched_watchers
耙路線顯示:
POST /watched_watchers(.:format) watched_watchers#create
所以我難倒任何幫助表示讚賞。提前致謝。
奇怪!是否嘗試重新啓動服務器..? – aBadAssCowboy
將您的模型重命名爲'WatchedWatcher'(不帶下劃線)。 – usha
你有沒有嘗試從'create'動作中刪除你的邏輯並用'Rails.logger.info(「testing」)替換?這將允許您查看該操作是否真的被發現,但是您的系統只是被錯誤捕獲 –