Ruby on Rails
Thursday, March 27, 2014
Thanks for your answers. I already know cancancan, but it doesn't solve my issue. I'm looking for a way to use cancan to determine my strong parameters (see my examples), not cancan to use strong parameters.
Am Dienstag, 25. März 2014 23:00:29 UTC+1 schrieb Sebastian Gaul:
-- Am Dienstag, 25. März 2014 23:00:29 UTC+1 schrieb Sebastian Gaul:
Hello Rails World,does anybody know a good solution for Strong Parameters in a Rails app authorized by Cancan (or a similar authorization gem)?def user_paramsif current_user.admin?params.require(:user).permit!elseparams.require(:user).permit(:password, :password_confirmation) endendNow I want to do this the "Cancan way". My first idea looks strange to me:def user_paramsif can? :edit_all_attributes, Userparams.require(:user).permit!elsif can? :edit_password, Userparams.require(:user).permit(:password, :password_confirmation) endendHow would you realize the attribute level in Cancan? :edit_all_attributes and :edit_password scales very badly if more user roles and optional attributes are involved. It would be nice if allowed attributes are defined in Cancan's Ability class and used automatically to determine strong parameters.Do you Cancan plugins or replacements that allow a more satisfying attribute level authorization and/or strong parameters integration?
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/99f5c61b-f3c8-4910-b968-b5a75cc51742%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment