Files
openfoodnetwork/lib/tasks/users.rake
Pau Perez 80edfe469c Task to remove limit of ent. that can be created
It does so by updating a user's enterprise_limit attribute to the
maximum integer the database supports.

This is used at least in Katuma to remove the limitation of the number
of enterprises a user can create. This is the agreement the community
reached for the pricing plans.

Eventually, this logic could be triggered with a button from the UI but
for now this is for internal usage only.
2019-10-24 15:53:43 +02:00

28 lines
603 B
Ruby

require 'csv'
namespace :ofn do
desc 'remove the limit of enterprises a user can create'
task :remove_enterprise_limit, [:user_id] => :environment do |_task, args|
RemoveEnterpriseLimit.new(args.user_id).call
end
class RemoveEnterpriseLimit
# rubocop:disable Style/NumericLiterals
MAX_INTEGER = 2147483647
# rubocop:enable Style/NumericLiterals
def initialize(user_id)
@user_id = user_id
end
def call
user = Spree::User.find(user_id)
user.update_attribute(:enterprise_limit, MAX_INTEGER)
end
private
attr_reader :user_id
end
end