Skip to content

Instantly share code, notes, and snippets.

View gabeodess's full-sized avatar

Gabe Odess gabeodess

  • RigUp
  • Austin TX
  • 13:32 (UTC -05:00)
View GitHub Profile
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
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!
@gabeodess
gabeodess / custom_arel.rb
Last active September 20, 2020 23:16
An example of how to add a custom predicate to Arel
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
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|
@gabeodess
gabeodess / ransackable_scopes.rb
Created January 14, 2016 16:51 — forked from frahugo/gist:8ceb262e929d4c0a9575
Ransack with JSONB query
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
ActiveAdmin.setup do |config|
# == Site Title
#
# Set the title that is displayed on the main layout
# for each of the active admin pages.
#
config.site_title = "NWMedTech"
# Set the link url for the title. For example, to take
# users to your main site. Defaults to no link.
# @order.to_slack_json
{
:message => "this is a test"
}
find: https://order.dominos.com/power/store-locator?s=${line1}&c=${line2}&type=${type}
method: GET
s: Street Address
c: City, State and/or Postal Code
type: Delivery or Carryout
store info: https://order.dominos.com/power/store/${storeID}/profile
method: GET
storeId: store id number
@gabeodess
gabeodess / basic.js
Created March 7, 2016 22:51
Angular with Turbolinks
$(document).on('page:load', function(){
$('[ng-app]').each(function(){
angular.bootstrap(this);
});
});
$cat dump.sql | psql nwmedtech_production
SET
SET
SET
SET
SET
SET
ERROR: database "callcenter" already exists
ERROR: role "nwmedtech" does not exist
You are now connected to database "callcenter" as user "gabeodess".