不知道这个问题之前有没有回答过。
为用户提供自定义路线。如果我直接访问用户 /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
我究竟做错了什么?