开发者

Restful model ownership validations

开发者 https://www.devze.com 2023-02-02 13:22 出处:网络
I know there are role based authorization gems/plugins for rails to determine if a user can do things based on which role their in.However, is there a best-practice approach to hiding actions from use

I know there are role based authorization gems/plugins for rails to determine if a user can do things based on which role their in. However, is there a best-practice approach to hiding actions from users based on ownership? ie: the show/edit/destroy methods for a user should only be available if they're being performed on the curren开发者_开发知识库tly logged in user id. Hopefully that makes sense, but I've written some methods to protect against non-owners accessing methods and its become a bit bloated and ugly.


Look at cancan's implementation.


I can recommend on restful_authentication( https://github.com/technoweenie/restful-authentication ). quick tutorial http://railscasts.com/episodes/67-restful-authentication

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号