Skip to content

Instantly share code, notes, and snippets.

View braidn's full-sized avatar
🏰
Storming

Braden Douglass braidn

🏰
Storming
View GitHub Profile
class Case
def self.build(params)
new.build(params)
end
def build(params)
create_airware_case(params)
end
private
@braidn
braidn / Gemfile.rb
Created June 2, 2014 15:07
rails assets gemfile
source 'https://rails-assets.org'
@braidn
braidn / api.stubLists.reason.rb
Last active August 29, 2015 14:02
API Test/Code
def find_list_id(name)
@api.lists["data"].detect { |r| r["name"] == name }["id"]
end
def list_id
@list_id ||= find_list_id(@list_name)
end
module Spree
class Promotion
module Rules
class LimitOnePerUserPromotionRule < PromotionRule
def eligible?(order)
@email = order.email
return completed_orders_using_promotion < 1
end
if defined?(AssetSync)
AssetSync.configure do |config|
config.fog_provider = 'AWS'
config.fog_directory = ENV['FOG_BUCKET']
config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
# Delete files from the store
# config.existing_remote_files = 'keep'
#
module RCMS
class Asset < ActiveRecord::Base
self.table_name = 'rcms_assets'
end
end
module RCMS
class Asset < ActiveRecord::Base
self.table_name = 'rcms_assets'
self.inheritance_column = :_type_disabled
end
end
#does not work (has column name 'type')
module ApplicationHelper
include Spree::BaseHelper
def checkout_steps
states = checkout_states
current_index = states.index(@order.state) + 1
order_title = @order.state.titleize
return "Step #{current_index} of #{states.length}: #{order_title}"
end
def checkout_image_url(product)
@braidn
braidn / api_decorator.rb
Created September 4, 2014 02:05
Spree API Mods
::Spree::Api::ApiHelpers.module_eval do
def taxon_attributes
[:id, :name, :pretty_name, :permalink, :position, :parent_id, :taxonomy_id, :icon_url]
end
def user_attributes
[:id, :email, :created_at, :updated_at, :first_name, :last_name, :phone, :spree_api_key, :authentication_token, :encrypted_password]
end
@braidn
braidn / paperclip.rb
Last active August 29, 2015 14:06
Paperclip Initializer
if ENV['USE_S3'] == 'true'
Paperclip::Attachment.default_options[:storage] = :fog
Paperclip::Attachment.default_options[:fog_credentials] = { provider: "AWS", aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'], aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'] }
Paperclip::Attachment.default_options[:fog_directory] = ENV['FOG_BUCKET']
Paperclip::Attachment.default_options[:path] = '/app/public/assets/products/:id/:style/:basename.:extension'
Paperclip::Attachment.default_options[:fog_host] = ENV['S3_HOST_ALIAS']
Paperclip::Attachment.default_options[:url] = ':s3_alias_url'
Spree::Image.attachment_definitions[:attachment][:path] = 'public/assets/products/:id/:style/:basename.:extension'
else
Paperclip::Attachment.default_options[:storage] = :fog