I hereby claim:
- I am christopherstyles on github.
- I am cstyles (https://keybase.io/cstyles) on keybase.
- I have a public key ASDMo_KnIYYDOPwEH-1nHS3kcLZ-1WGlaaqDUQ7VnnFriQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| # app/models/user.rb | |
| class User < ActiveRecord::Base | |
| has_many :permissions | |
| has_many :roles, through: :permissions | |
| scope :by_role, lambda { |role_ids| | |
| joins(:permissions).where(permissions: { role_id: Array.wrap(role_ids) }) | |
| } | |
| ransacker :role, |
| # admin/user.rb | |
| ActiveAdmin.register User do | |
| filter :role_in_all, as: :select, | |
| multiple: true, | |
| collection: -> { Role.order(name: :asc).all } | |
| end |
| module YourNamespace | |
| class Item < ActiveRecord::Base | |
| end | |
| end | |
| YourNamespace.require_sti_dependencies(:item) |
| #!/usr/bin/env ruby | |
| $:.unshift 'spec' | |
| require 'rspec' | |
| require 'rails_helper' | |
| require 'benchmark/ips' | |
| spec = ARGV[0] |
| #!/usr/bin/env ruby | |
| $:.unshift 'spec' | |
| require 'rspec' | |
| require 'rails_helper' | |
| spec = ARGV[0] | |
| # ----------------------------------------------------------------------------- |
| class ArchiveInactiveUsers | |
| def self.call(users) | |
| users.each do |user| | |
| UnsubscribeUserFromList.call(user) | |
| SendGoodbyeEmail.call(user) | |
| RemoveUserComment.call(user) | |
| end | |
| end | |
| end |
| [1] pry(main)> user = User.find(99) | |
| [2] pry(main)> RemoveUserComments.call(user) | |
| => "User #99 was removed." |
| class ArchiveUserWorker | |
| include Sidekiq::Worker | |
| def perform(user) | |
| UnsubscribeUserFromList.call(user) | |
| end | |
| end |