concept ProjectPolicy in category rails
appears as: ProjectPolicy, ProjectPolicy

This is an excerpt from Manning's book Rails 4 in Action: Revised Edition of Rails 3 in Action.
You’ve called authorize with an instance of a Project, so Pundit has determined that it should use a ProjectPolicy class to check permissions for it. (If you had tried to authorize a Ticket instance, it would look for a TicketPolicy class instead. This is another example of convention over configuration.)
You haven’t yet defined the ProjectPolicy class, but Pundit comes with a Rails generator to do it for you. You can easily generate a ProjectPolicy with the following command.
Listing 8.12. Testing the show? permission on ProjectPolicy
permissions :show? do let(:user) { FactoryGirl.create :user } let(:project) { FactoryGirl.create :project } it "blocks anonymous users" do expect(subject).not_to permit(nil, project) end it "allows viewers of the project" do assign_role!(user, :viewer, project) expect(subject).to permit(user, project) end it "allows editors of the project" do assign_role!(user, :editor, project) expect(subject).to permit(user, project) end it "allows managers of the project" do assign_role!(user, :manager, project) expect(subject).to permit(user, project) end it "allows administrators" do admin = FactoryGirl.create :user, :admin expect(subject).to permit(admin, project) end it "doesn't allow users assigned to other projects" do other_project = FactoryGirl.create :project assign_role!(user, :manager, other_project) expect(subject).not_to permit(user, project) end end