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
@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 |
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
# Example Controller | |
class SomeController < ApplicationController | |
def index | |
@categorized_products = Product.categorized | |
end | |
end | |
# Example view |
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
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' |
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
available_methods = ['one', 'two', 'three'] | |
filtered_methods = available_methods.find_all do |method| | |
method != 'one' | |
end | |
p filtered_methods | |
# => ['two', 'three'] |
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
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 |
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
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 |
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
# 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 |
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 Property < ActiveRecord::Base | |
has_many :features | |
has_many :ammenities, :through => :features | |
end | |
class Feature < ActiveRecord::Base | |
belongs_to :ammenity |
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
def wedgie_tws | |
@products = Product.find :all, :conditions => {:name_data => ['double-agent', 'nitrane-contraband', 'delta-mvmnt', 'contraband', 'bandita-contraband']} | |
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 Object | |
def if_present?(&blk) | |
if blk.arity == -1 | |
instance_eval(&blk) | |
else | |
blk.call(self) | |
end | |
end | |