I working on an app with user authorization. It has a List and User classes. The authentication was built with Ryan Bates http://railscasts.com/episodes/270-authentication-in-rails-3-1
I’m not sure about authorization process. I read about cancan gem. But i could not understand.
I want to achieve this:
- User only able to view/edit/delete his own list.
- User only able to view/edit/delete his own profile(user class).
I don’t implement user level right now. No guess or admin.
How to use before_filter method in list and User controller with current_user instance?
Since you are defining
current_userin the application controller, this is easy. You can usebefore_filterlike this in the Users controller:You should add a similar method to UsersController to check if it is his profile, he is editing.
Also, have a look at Devise which is the recommended plugin for authentication purposes.