Skip to content

Instantly share code, notes, and snippets.

View kalupa's full-sized avatar

Paul Kalupnieks kalupa

View GitHub Profile
def update_cousin_variants_by_variant_value(variant_value)
first_sibling_value = variant_value.category.variant_values.first
existing_variants_with_this_value = self.variants.includes(:variant_values).where('variant_value_id = ?', first_sibling_value.id)
new_variants = []
existing_variants_with_this_value.each do |variant|
new_variant = product.variant.create(price: self.price)
variant.variant_values.each do |old_variant_value|
if old_variant_value.variant_category != variant_value.variant_category
new_variant.variant_values << old_variant_value
def cleanup_variants
self.variants.each do |variant|
variant.variant_values.delete(self)
variant.destroy if variant.variant_values.count == 0
end
end
%input{ :name => "page_url",
:type => "text",
:placeholder => "http://YourProductSite.com",
:maxlength => 200,
:"ng-model" => "product_advanced.page_url",
:"ng-disabled" => "!product_advanced.has_landing_page",
:"ng-change" => "change(product_advanced)",
:"ng-required" => "product_advanced.has_landing_page",
:"enforce-uri-scheme" => "" }
scope.states = (filter gon.states, country_id: scope.taxRate.country_id)
scope.states = state for state in gon.states when state.country_id is scope.taxRate.country_id
Started PUT "/orders/161c9a7d55d" for 127.0.0.1 at 2013-05-06 21:11:33 -0400
Processing by OrdersController#update as */*
Parameters: {"order"=>{"line_items_attributes"=>{"0"=>{"id"=>"455", "quantity"=>"2", "variant_id"=>"173"}}}, "id"=>"161c9a7d55d"}
Order Load (0.4ms) SELECT "orders".* FROM "orders" WHERE "orders"."token" = '161c9a7d55d' LIMIT 1
(0.1ms) BEGIN
LineItem Load (0.2ms) SELECT "line_items".* FROM "line_items" WHERE "line_items"."order_id" = 216 AND "line_items"."id" IN (455)
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = 4 LIMIT 1
Product Load (0.5ms) SELECT "products".* FROM "products" WHERE "products"."id" = 9 LIMIT 1
CACHE (0.0ms) SELECT "products".* FROM "products" WHERE "products"."id" = 9 LIMIT 1
Image Load (0.2ms) SELECT "images".* FROM "images" WHERE "images"."product_id" = 9 ORDER BY ordering ASC
attr_accessible :one, :two, :three, :four, :five, :six, :seven, :eight, :nine, :ten, :eleven,
:twelve, :thirteen, :fourteen, :fifteen
@kalupa
kalupa / lines.rb
Last active December 21, 2015 02:28 — forked from joannou/lines.rb
attr_accessible :one,
:two,
:three,
:four,
:five,
:six,
:seven,
:eight,
:nine,
:ten,
@kalupa
kalupa / commit-msg
Created October 8, 2013 17:27
Bash commit-msg hook script to prepend JIRA issue ids based on the branch name
#!/bin/bash
is_project_id()
{
project_ids=(BLOG OPS SYS IT PS PUB SS LP EX UBWEB)
found=0
for id in "${project_ids}"; do
if [[ $id == $1 ]]; then
found=1
@kalupa
kalupa / .vimrc
Created October 8, 2013 23:59 — forked from sdizier/.vimrc
" Strip trailing whitespace
function! <SID>StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let @/=_s
{
"eqeqeq": true,
"latedef": true,
"noarg": true,
"nonew": true,
"quotmark": true,
"undef": true,
"unused": true,
"trailing": true,
"maxdepth": 3,