Skip to content

Instantly share code, notes, and snippets.

def cached_unread_messages_count
Rails.cache.fetch([self, "unread_messages_count"]) { Receipt.where(receiver_id: self.id, mailbox_type: 'inbox', is_read: false).size }
end
class Listing < ActiveRecord::Base
include AlgoliaSearch
include ListingSearch
end
class Listing < ActiveRecord::Base
include AlgoliaSearch
algoliasearch per_environment: true, if: :saleable? do
attribute :title, :designer, :price, :description, :size, :category, :price_drops, :dropped, :price_updated_at, :created_at, :cover_photo, :images_processed, :bumped_at, :location, :strata, :retina_cover_photo, :retina_cover_height, :retina_cover_width, :followerno
attributesToIndex ['unordered(designer)', 'unordered(title)', 'unordered(description)', 'category', 'size', 'price']
customRanking ['desc(price_updated_at)']
ranking ['custom', 'desc(followerno)', 'typo', 'geo', 'words', 'proximity', 'attribute', 'exact']
synonyms [
def self.correct_name(designer)
if ["Apc", "A.P.C"].include?(designer)
return "A.P.C."
elsif ["Jcrew","J Crew","J.Crew"].include?(designer)
return "J. Crew"
elsif ["10.Deep", "10Deep", "10deep"].include?(designer)
return "10 Deep"
elsif ["All Saints"].include?(designer)
return "Allsaints"
elsif ["Wings And Horns", "Wings Horns", "Wings+Horns"].include?(designer)
$('.deslinks').hover( function() {
$('.deslinks').addClass('popout');
$('.deslinks.popout').animate({height:495},300)
$('.deslinksbehind').show();
}, function() {
$('.deslinksbehind').hide();
$('.deslinks.popout').animate({height:155},300, function() {
$('.deslinks').removeClass('popout');
})
}
May 21 08:19:53 grailed app/web.1: Processing by ListingsController#update as HTML
May 21 08:19:53 grailed app/web.1: Started PUT "/listings/7066-pointer-pointer-chukka-boots" for 98.230.44.241 at 2014-05-21 15:19:53 +0000
May 21 08:19:53 grailed app/web.1: Parameters: {"utf8"=>"✓", "authenticity_token"=>"PcdjpThIOOCdJJnCAovT9oyI8vc/qpyu9XT957qXsoQ=", "listing"=>{"user_id"=>"1240", "string_of_urls"=>"", "category"=>"footwear", "designer"=>"Pointer", "title"=>"Pointer chukka boots", "color"=>"", "size"=>"12", "price"=>"10", "buynow"=>"0", "shipcost"=>"", "shipto"=>"", "makeoffer"=>"1", "paypal_id"=>"adswim@gmail.com", "description"=>"This is a pair of Pointer brand chukka boots. They're made in Portugal and originally cost $100. \r\n\r\nWorst damage is on the sole and midsole although the suede has some stains that could be cleaned. The rubber sole and midsole have signs of wear and could be cleaned. The insole also has some markings from wear. \r\n\r\nNo int. shipping \r\nThanks ", "photos_attributes"=
- #@big_designer_list is an array of 850 strings like "J Crew"
- @big_designer_list.each do |designer|
.designerselect
.designerselected{:id => designer.parameterize.gsub( /\W/, '')}
= link_to designer, '#'
@ArunGupta25
ArunGupta25 / error
Last active January 1, 2016 04:38
strange heroku push error
Fetching repository, done.
Counting objects: 10, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 551 bytes | 0 bytes/s, done.
Total 6 (delta 5), reused 0 (delta 0)
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-1.9.3
Running `rake db:migrate` attached to terminal... up, run.5405
Connecting to database specified by DATABASE_URL
Migrating to DeviseCreateUsers (20130912232427)
Migrating to CreateListings (20130913002812)
Migrating to CreatePhotos (20130913190236)
Migrating to AddDetailsToListings (20130914211523)
Migrating to RemoveTypeFromListing (20130916223611)
Migrating to AddCategoryToListing (20130916223708)
Migrating to CreateMailboxer (20130919193851)
Migrating to AddNotifiedObject (20130919193852)
@ArunGupta25
ArunGupta25 / paypalcall.rb
Created December 9, 2013 22:44
authentication failure on paypal classic api
require 'paypal-sdk-adaptivepayments'
#set the api credentials
PayPal::SDK.configure(
:mode => "live",
:app_id => "APP-8TA367141A153745A",
:username => "arun_api1.wakemate.com",
:password => #HIDDEN,
:signature => "A5apZv808uLSmMYKU32Uz0S3VglPA4gSn10Qcf3-iJjfWBq-bMpQxEh8y")