Module: Formol::Permissions::SpecialRights

Defined in:
lib/formol/generators/install/templates/lib/permissions/special_rights.rb

Overview

add methods to this module to define some rights that acts differently than just checking if user has right for his profile.

For instance, a user can edit a post without having ‘edit_post’ right if he wrotes it, he’s able to edit it

Instance Method Summary collapse

Instance Method Details

#able_to_edit_post?(post) ⇒ Boolean

a user can edit a post if he wrotes it

Returns:

  • (Boolean)


15
16
17
# File 'lib/formol/generators/install/templates/lib/permissions/special_rights.rb', line 15

def able_to_edit_post?(post)
  has_right?(:edit_post) || post.user_id == user.id
end

#able_to_edit_topic?(topic) ⇒ Boolean

a user can edit a topic if he wrotes it

Returns:

  • (Boolean)


10
11
12
# File 'lib/formol/generators/install/templates/lib/permissions/special_rights.rb', line 10

def able_to_edit_topic?(topic)
  has_right?(:edit_topic) || topic.user_id == user.id
end