Sha256: 7befd261ae834eff08713d5cc86785ac274627859e4136c0176d211665a36475
Contents?: true
Size: 809 Bytes
Versions: 1
Compression:
Stored size: 809 Bytes
Contents
# frozen_string_literal: true class Spree::ReviewsAbility include CanCan::Ability def initialize(user) review_ability_class = self.class can :create, Spree::Review do |_review| review_ability_class.allow_anonymous_reviews? || user.email.present? end can :create, Spree::FeedbackReview do |_review| review_ability_class.allow_anonymous_reviews? || user.email.present? end # You can read your own reviews, and everyone can read approved ones can :read, Spree::Review do |review| review.user == user || review.approved? end # You can only change your own review can [:update, :destroy], Spree::Review do |review| review.user == user end end def self.allow_anonymous_reviews? !Spree::Reviews::Config[:require_login] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
solidus_reviews-1.3.0 | app/models/spree/reviews_ability.rb |