Skip to content

Instantly share code, notes, and snippets.

View beaucollins's full-sized avatar
🃏
Special Author

Beau Collins beaucollins

🃏
Special Author
View GitHub Profile
@results = Product.find(:all, :conditions => conditions, :order => 'weight ASC, id ASC').inject([]) do |result_array, product|
result_array << {:product => product, :shoe_sizes => product.shoe_sizes.find(:all, :conditions => ["min_weight >= ? AND max_weight <= ?"])}
end
# Example Controller
class SomeController < ApplicationController
def index
@categorized_products = Product.categorized
end
end
# Example view
def results
return @results unless @results.nil?
# Strategy
# First always, consider the weight range, right now we'll find where max_weight = :weight
conditions = ['', {}]
#conditions = ["weight_range_max = :weight", {:weight => self.weight}]
# If they choose kids for intended use then just find shoes for kids and ignore gender
#
if self.intended_use == 'kids'
available_methods = ['one', 'two', 'three']
filtered_methods = available_methods.find_all do |method|
method != 'one'
end
p filtered_methods
# => ['two', 'three']
require 'net/http'
http = Net::HTTP.new 'k2master.k2sportsdev.com'
#=> #<Net::HTTP k2master.k2sportsdev.com:80 open=false>
# API_KEY redacted for security
response = http.post '/inventory/status?api_key=API_KEY', File.read('pe.xml'), {'content-type' => 'text/xml'}
#=> #<Net::HTTPOK 200 OK readbody=true>
response.body
var Timer = function(end, options){
if(!options) options = {};
if(!options['timerInterval']) options['timerInterval'] = 1;
if(!options['periods']) options['periods'] = {
'milliseconds' : 1,
'seconds' : 1000,
'minutes' : 60,
'hours' : 60,
'days' : 24,
'weeks' : 7
# Unique for each merchant. Your merchant_group_id is located in the PowerReviews Dashboard > Merchant
# Group Properties section.
PowerReviews::Config.merchant_group_id = 11979
# ID representing your website (default value is "1"). If you have multiple websites and would like to
# integrate PowerReviews onto each site, we can set your account as a Master Merchant. This enables
# review sharing and consolidated management among your different websites. When using the “Master
# Merchant” configuration, you assign a different Site ID to each site that will have reviews. This ID
# can be your own internal ID for the site or an ID assigned by PowerReviews. If you are implementing
class Property < ActiveRecord::Base
has_many :features
has_many :ammenities, :through => :features
end
class Feature < ActiveRecord::Base
belongs_to :ammenity
def wedgie_tws
@products = Product.find :all, :conditions => {:name_data => ['double-agent', 'nitrane-contraband', 'delta-mvmnt', 'contraband', 'bandita-contraband']}
end
class Object
def if_present?(&blk)
if blk.arity == -1
instance_eval(&blk)
else
blk.call(self)
end
end