Created
February 9, 2016 18:33
-
-
Save stabenfeldt/220eeb8dd8d403d0ba52 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Spree | |
class MultiVendorAbility | |
include CanCan::Ability | |
def initialize(user) | |
user ||= Spree::User.new # guest user (not logged in) | |
if user.admin? | |
can :manage, :all | |
puts "IS admin" | |
else | |
can :read, :all | |
puts "NOT admin" | |
end | |
can :manage, Spree::StockItem, :stock_location_id => user.stock_locations.present? && user.stock_locations.first.id | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment