O'Reilly logo

Learning Devise for Rails by Nia Mutiara, Hafiz, Giovanni Sakti

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Advanced CanCan usages

The previous abilities we learned through our CollabBlogs application are enough for us to get started. However, what if our application requires complex authorization rules? We have a few remaining complex rules unimplemented, and the abilities we have applied are far simpler than those complex rules.

After we have plenty of rules, we should try to simplify parts of the authorization process and test the rules' correctness. This is to ensure our application behaves as expected.

In this section, we are going to discuss defining rules using SQL, simplifying authorization checks on controllers, and ensuring abilities' correctness.

Defining rules using SQL

As mentioned before, the can and cannot methods we defined in app/models/abilities.rb ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required