У меня проблема, когда я получаю доступ к пользователям с cancan, сказал: «У вас нет доступа к этой странице». вот мой код:devise + cancan не распознает способность
class Ability
include CanCan::Ability
def initialize(user)
if user.tipo == 'c'
can :manage, :User
end
end
end
и вот мой контроллер Пользователь
class UserController < ApplicationController
load_and_authorize_resource
def index
@users = User.excludes(:id => current_user.id)
end
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
flash[:notice] = "Successfully created User."
redirect_to root_path
else
render :action => 'new'
end
end
def edit
@user = User.find(params[:id])
end
def update
@user = User.find(params[:id])
params[:user].delete(:password) if params[:user][:password].blank?
params[:user].delete(:password_confirmation) if params[:user][:password].blank? and params[:user][:password_confirmation].blank?
if @user.update_attributes(params[:user])
flash[:notice] = "Successfully updated User."
redirect_to root_path
else
render :action => 'edit'
end
end
def destroy
@user = User.find(params[:id])
if @user.destroy
flash[:notice] = "Successfully deleted User."
redirect_to root_path
end
end
end
и здесь мои маршруты
Rails.application.routes.draw do
resources :proyects
devise_for :users, :controllers => {:registrations => "users/registrations"}
resources :users, :controller => "user"
Некоторые тело знает, как решить эту проблему ?? или кто-то только что произошло
заранее!
Вы должны сказать нам, какие шаги ты доводя ошибки и принять некоторые основные шаги отладки самостоятельно. Как и проверка того, что возвращает 'current_user'. – max