Sha256: 583eab7fb20a0dac27fe2a9122f24bb3b1c59e5ea2e38813967cfb7a998a2834

Contents?: true

Size: 558 Bytes

Versions: 19

Compression:

Stored size: 558 Bytes

Contents

class AddSubscriberRoleToSpreeRoles < ActiveRecord::Migration
  def up
    Spree::Role.where(name: "subscriber").first_or_create
    Spree::Subscription.includes(:user).uniq.each do |subscription|
      subscription.add_role_subscriber unless subscription.user.has_spree_role?('subscriber')
    end
  end

  def down
    Spree::Subscription.includes(:user).uniq.each do |subscription|
      subscription.remove_role_subscriber if subscription.user.has_spree_role?('subscriber')
    end
    Spree::Role.where(name: "subscriber").first.try(:destroy)
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
spree_account_recurring-2.0.0 db/migrate/20131202110012_add_subscriber_role_to_spree_roles.rb
spree_account_recurring-1.3.1 db/migrate/20131202110012_add_subscriber_role_to_spree_roles.rb
spree_account_recurring-1.2.1 db/migrate/20131202110012_add_subscriber_role_to_spree_roles.rb
spree_account_recurring-1.3.0 db/migrate/20131202110012_add_subscriber_role_to_spree_roles.rb
spree_account_recurring-1.2.0 db/migrate/20131202110012_add_subscriber_role_to_spree_roles.rb
spree_account_recurring-1.1.5 db/migrate/20131202110012_add_subscriber_role_to_spree_roles.rb
spree_account_recurring-1.0.7 db/migrate/20131202110012_add_subscriber_role_to_spree_roles.rb
spree_account_recurring-1.1.4 db/migrate/20131202110012_add_subscriber_role_to_spree_roles.rb
spree_account_recurring-1.0.6 db/migrate/20131202110012_add_subscriber_role_to_spree_roles.rb
spree_account_recurring-1.0.5 db/migrate/20131202110012_add_subscriber_role_to_spree_roles.rb
spree_account_recurring-1.1.3 db/migrate/20131202110012_add_subscriber_role_to_spree_roles.rb
spree_account_recurring-1.1.2 db/migrate/20131202110012_add_subscriber_role_to_spree_roles.rb
spree_account_recurring-1.0.4 db/migrate/20131202110012_add_subscriber_role_to_spree_roles.rb
spree_account_recurring-1.0.3 db/migrate/20131202110012_add_subscriber_role_to_spree_roles.rb
spree_account_recurring-1.0.2 db/migrate/20131202110012_add_subscriber_role_to_spree_roles.rb
spree_account_recurring-1.1.1 db/migrate/20131202110012_add_subscriber_role_to_spree_roles.rb
spree_account_recurring-1.1.0 db/migrate/20131202110012_add_subscriber_role_to_spree_roles.rb
spree_account_recurring-1.0.1 db/migrate/20131202110012_add_subscriber_role_to_spree_roles.rb
spree_account_recurring-1.0.0 db/migrate/20131202110012_add_subscriber_role_to_spree_roles.rb