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
Customer.find(:all, :include => :posts).each do |customer| | |
if !customer.posts.blank? | |
add customer_posts_path(customer.id) | |
customer.posts.each do |post| | |
x = post.id | |
#add customer_posts_path(:customer_id => customer.id, :id => post.id) | |
add customer_posts_path(customer.id, x) | |
end | |
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
<url> | |
<loc> | |
http://www.autopartstomorrow.com/customers/5/posts.1 | |
</loc> | |
<lastmod>2011-12-02T23:10:26+00:00</lastmod> | |
<changefreq>weekly</changefreq> | |
<priority>0.5</priority> | |
</url> |
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
$(document).ready(function() { | |
var options = { | |
target: '#div_effect', | |
type: 'post', | |
}; | |
$("#post_comment_button").click(function() { | |
$('#new-comment-form').submit(function() { | |
// please don't redirect me | |
// instead inject my new comment into the list |
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
STATUSES = Order.all.collect{|x| x.status}.uniq | |
# Currently : STATUSES = ["SHIPPED", "PROCESSING", "RECEIVED", "INCOMPLETE", "VOIDED", "REFUNDED", "FRAUDULENT", "ON HOLD"] | |
validates_inclusion_of :status, :in => STATUSES | |
STATUSES.map{|x| x.downcase.gsub(" ", "_")}.each_with_index { |s,index| named_scope s, :conditions => { :status => STATUSES[index] } } |
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
named_scope :cart_products_not_empty, | |
:joins => :cart_products, | |
:group => 'cart_products.cart_id', | |
:having => "count(cart_products.cart_id) >= 1" | |
named_scope :cart_components_not_empty, | |
:joins => :cart_components, | |
:group => 'cart_components.cart_id', | |
:having => "count(cart_components.cart_id) >= 1" |
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
# If the cart already has this product in it, | |
if existing_cart_product = cart.cart_products.find_by_part_number_id(@cart_product.part_number_id) | |
# And if the current quantity in cart exceeds or equals the available quantity | |
if existing_cart_product.quantity >= available_quantity | |
# Set the quantity in cart to the available quantity, and add 0 of the requested quantity to the cart. | |
existing_cart_product.update_attributes(:quantity => available_quantity) | |
@addl_msg << "Quantity has been depleted for this item. There are #{existing_cart_product.quantity} units in your cart. " | |
@cart_product.quantity = 0 | |
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
#To load in-stock parts ordered within last 30 or 7 days: | |
#For PartNumbers I have: | |
named_scope :with_id, lambda {|id| { :conditions => { :id => id } } } | |
named_scope :stocked, :conditions => ['quantity > ?', 0] | |
#For Orders I have: | |
named_scope :within_days, lambda { |number| {:conditions => ["created_at > ? AND transaction_id IS NOT NULL", Time.now - number.days] } } | |
PartNumber.with_id(Order.within_days(7).map{|o| o.order_products.map{|op| op.part_number_id}}.flatten.uniq).stocked.count |
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 hot_parts | |
# initialize some empties | |
hps = [] | |
hp = false | |
# get 6 random parts | |
while(hps.length < 6 ) | |
# Set flag variable to ensure entry into inner loop first time around | |
first = true | |
# Validate uniqueness and non nillishness |
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
#greetings { | |
width: 100%; | |
height: auto; | |
color: #999999; | |
background: #4f4f4f; | |
background: -moz-linear-gradient(top, #4f4f4f 0%, #666666 43%, #7f7f7f 100%); | |
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#4f4f4f), color-stop(43%,#666666), color-stop(100%,#7f7f7f)); | |
background: -webkit-linear-gradient(top, #4f4f4f 0%,#666666 43%,#7f7f7f 100%); | |
background: -o-linear-gradient(top, #4f4f4f 0%,#666666 43%,#7f7f7f 100%); | |
background: -ms-linear-gradient(top, #4f4f4f 0%,#666666 43%,#7f7f7f 100%); |
OlderNewer