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
class Registration < ActiveRecord::Base | |
scope :nhb_consent_eq, -> (enum = "yes") { | |
where("document @> ?", { nhb_consent: { value: enum } }.to_json ) | |
} | |
private | |
def self.ransackable_scopes(auth_object = nil) | |
%i(nhb_consent_eq) | |
end |
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 Arel | |
def self.add_predicate(predicate, operator) | |
$method_name = predicate | |
$operator = operator | |
$class_name = $method_name.to_s.camelcase | |
module Arel::Predications | |
define_method($method_name) do |right| |
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 Arel::Predications | |
def has_key(right) | |
Arel::Nodes::HasKey.new(self, quoted_node(right)) | |
end | |
end | |
class Arel::Nodes::HasKey < Arel::Nodes::Binary | |
def operator; :"?" end | |
end |
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
class WholesaleOrdersController < ApplicationController | |
PERMITTED_PARAMS = [:address_id, :payment_method, :pickup, :shipping_method, :wholesale_order_items_attributes => [:ounces, :quantity, :great_coffee_id]] | |
before_filter :activated_check! | |
before_filter :load_wholesale_order, :only => [:show, :pay, :send_check] | |
before_filter :new_wholesale_order_from_params, :only => [:create, :shipping] | |
skip_before_filter :authenticate_user! | |
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
class ImportCropsterDataJobTest < ActiveJob::TestCase | |
test "create blend batches" do | |
@blend = FactoryGirl.create(:great_coffee, :blend => true) | |
@c1 = @blend.blend_coffees.first | |
@c2 = @blend.blend_coffees.last | |
@c1.update_attribute(:cropster_id, 1) | |
@c2.update_attribute(:cropster_id, 2) | |
@lot_id = 1654109 | |
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
ActiveAdmin.register User do | |
scope("all", :default => true) | |
scope("setup a subscription"){ |scope| scope.where("(SELECT COUNT(*) FROM subscriptions WHERE subscriptions.user_id = users.id LIMIT 1) = 1") } | |
scope("canceled"){ |scope| scope.where(" | |
(SELECT COUNT(*) FROM subscriptions WHERE subscriptions.user_id = users.id LIMIT 1) = 1 AND | |
(SELECT COUNT(*) FROM subscriptions WHERE subscriptions.user_id = users.id AND subscriptions.archived_at IS NULL) = 0 | |
") } | |
scope("active"){ |scope| scope.where(:id => Subscription.find_active.select(:user_id)) } | |
# scope("30 days +"){ |scope| scope.where(:id => Subscription.find_active.where("subscriptions.created_at < ?", 30.days.ago).select(:user_id)) } |
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
Subscription Load (0.9ms) SELECT "subscriptions".* FROM "subscriptions" WHERE (subscriptions.away @> 'away_action => NULL') | |
=> 0 | |
Subscription Load (1.2ms) SELECT "subscriptions".* FROM "subscriptions" WHERE (subscriptions.away @> 'away_action => NULL' OR away ? 'away_action') | |
=> 34 | |
Subscription Load (2.4ms) SELECT "subscriptions".* FROM "subscriptions" WHERE ((away -> 'away_action') IS NULL) | |
=> 140 |
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
class User < ActiveRecord::Base | |
after_initialize do | |
def addresses.<<(val) | |
push(val) | |
user.save! | |
end | |
end | |
def addresses |
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
$bundle exec rake | |
Run options: --seed 62924 | |
# Running: | |
................autoprefixer: /home/rof/src/bitbucket.org/sharecoffee/share/app/assets/stylesheets/application.scss:6859:5: Gradient has outdated direction syntax. New syntax is like "to left" instead of "right". | |
autoprefixer: /home/rof/src/bitbucket.org/sharecoffee/share/app/assets/stylesheets/application.scss:6868:5: Gradient has outdated direction syntax. New syntax is like "to left" instead of "right". | |
........................................autoprefixer: /home/rof/src/bitbucket.org/sharecoffee/share/app/assets/stylesheets/coming_soon.scss:6859:5: Gradient has outdated direction syntax. New syntax is like "to left" instead of "right". | |
autoprefixer: /home/rof/src/bitbucket.org/sharecoffee/share/app/assets/stylesheets/coming_soon.scss:6868:5: Gradient has outdated direction syntax. New syntax is like "to left" instead of "right". |
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
#<HelloSign::Resource::SignatureRequest:0x007fe1d729c640 | |
@data= | |
{"signature_request_id"=>"051eb2733453faf3fb0c2703ffd9aaf7237c8df8", | |
"title"=>"test4", | |
"original_title"=>"test4", | |
"subject"=>"test4", | |
"message"=>nil, | |
"test_mode"=>true, | |
"metadata"=>#<HelloSign::Resource::BaseResource:0x007fe1d729c438 @data={}, @raw_data={}>, | |
"is_complete"=>false, |