我有一個rails應用程序,我正在遵循並取消關注用戶權限不是我有創建方法工作,但不是刪除方法,我不知道我爲什麼得到這個錯誤。沒有路由匹配[DELETE]「/跟着」rails
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :post
has_many :likes
has_many :follows
acts_as_commontator
end
class Follow < ActiveRecord::Base
belongs_to :user
end
class FollowsController < ApplicationController
def create
follow = Follow.new
follow.user_id = current_user.id
follow.follows = params[:user_id]
follow.save
redirect_to root_path
end
def destroy
follow = Follow.where('user_id = ? AND follows = ?',current_user.id,params[:user_id])
Follow.destroy
redirect_to root_path
end
def index
@users = User.all
end
end
我不知道爲什麼該方法不WO rking。
user_id字段是當前登錄用戶的字段,下面的字段是用戶遵循的用戶字段。
您可以發佈您的路由文件中的相關章節? – mysmallidea
devise_for:用戶 資源:喜歡 刪除 '遵循/:USER_ID'=> '如下#摧毀' 資源:帖子 資源:如下 安裝Commontator ::引擎=> '/ commontator' 根 'news_feed#指數' –