gpt4 book ai didi

ruby-on-rails - 自定义路由和声明授权

转载 作者:太空宇宙 更新时间:2023-11-03 18:01:38 25 4
gpt4 key购买 nike

不知道以前有没有人回答过这个问题。

为用户提供自定义路由。如果我直接访问用户/users/5 一切正常。如果我使用声明性授权尝试/profile 甚至/users/current_user,我会收到“找不到没有 ID 的用户”

map.profile "profile", :controller => "users", :action => "show"
map.edit_profile 'profile/edit', :controller => 'users', :action => 'edit', :conditions => { :method => :get }

我的 ApplicationController 有

before_filter { |c| Authorization.current_user = c.current_user }

我的 authorization_rules 有 user.id,也试过 current_user.id。

role :user do
includes :guest
has_permission_on :users, :to => [:show, :edit ] do
if_attribute :id => is { user.id }
end
end

我做错了什么?

最佳答案

对于自定义索引类型路由使用
filter_access_to:全部

而不是
filter_resource_access

我也是。

关于ruby-on-rails - 自定义路由和声明授权,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2981350/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com