Skip to content

How to use plans and acl in a simple way? #4

@gumayunov

Description

@gumayunov

This is boring:

  #./app/services/review_service.rb                             

  # Serivces can't use any current_user, so we have to          
  # pass some more options.                                     

  class ReviewService < BaseSevice                              

    def mark_featured(review_id, options)                       

      review = Review.find(review_id)                           

      AccessSchema.schema(:acl).require! review, :mark_featured, {     
        :role => options[:actor].roles,                         
      }                                                         

      AccessSchema.schema(:plans).require! review, :mark_featured, {   
        :plan => options[:actor].plan                           
      }                                                         

      review.featured = true                                    
      review.save!                                              

    end                                                         

  end                                                           

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions