Skip to content

Instantly share code, notes, and snippets.

View goldnuggets24's full-sized avatar

Mike Levine goldnuggets24

  • Collectionzz / University of North Carolina
  • Chapel Hill
View GitHub Profile
@goldnuggets24
goldnuggets24 / Upload Multiple Files and save
Created January 20, 2015 15:58
Add mutliple file uploads to Collection Craze through filepicker
@e = Item.find(50).pictures.first.image.split(",")
@e.each do f
@g = Picture.new(:image => f, :title => 'multiple file upload test', :user_id => 5, :item_id => 50, :description => "multi upload desc")
@g.save
end
# @e.destroy // eliminate orig image with multiple files in it???
@goldnuggets24
goldnuggets24 / gist:cc9feec349c32e416883
Created January 16, 2015 14:26
Get first 4 items returned from db where title matches searched criteria
@items += Item.where( "lower(title) ~* ?", "#{params[:s].downcase}".split(/,\s*/).map(&:strip).reject(&:empty?).first)
@items += Item.where( "lower(title) ~* ?", "#{params[:s].downcase}".split(/,\s*/).map(&:strip).reject(&:empty?).second)
@items += Item.where( "lower(title) ~* ?", "#{params[:s].downcase}".split(/,\s*/).map(&:strip).reject(&:empty?).third)
@items += Item.where( "lower(title) ~* ?", "#{params[:s].downcase}".split(/,\s*/).map(&:strip).reject(&:empty?).fourth)
class EmployeeDemographic < ActiveRecord::Base
#Start Activity Tracking
include PublicActivity::Model
include ::ActivityMethods
tracked except: :update, owner: -> (controller, model) { controller && controller.current_user }
tracked except: :update, account_id: -> (controller, model) { controller && controller.current_user.account_id }
tracked except: :update, user_id: -> (controller, model) { controller && model.user_id }
tracked except: :update, activity_type: -> (controller, model) { controller && "private" }
monitor_attr_changed :eeo_job_category, :employee_number, :ethnicity, :flsa_code, :hire_date, :performance_review_due, :termination_date, :veteran_status, :ssn
#End Activity Tracking
class Subscription < ActiveRecord::Base
belongs_to :deal
belongs_to :organization
validates_presence_of :email
attr_accessor :stripe_card_token, :email, :card_number, :card_code, :card_month, :card_year , :card
attr_accessible :organization_id, :deal_id, :stripe_card_token, :email, :name, :description, :card
- @email.deals.each_with_index do |deal, i|
- if i%6 == 0
%tr
= render :partial => 'admin/emails/gifts', :locals => {:deal => deal, :i => i}
- orgs = Organization.all.select{|o| o.deals.count > 0 }
- orgs.each do |org|
- @d = org.deals.where(:organization_id => org.id, :active => true)
- @c = @d.map(&:what)
.grid_2.alpha.omega
%h3<
= select_tag 'email_organization_ids[]', options_from_collection_for_select(@d, :id, :what), :prompt => org.name, :class => 'load-ad', :style => 'width: 90%;'
.ad
- @email.organizations.each_with_index do |organization, i|
- if i%5+1 == col
%tr
= render :partial => 'admin/emails/banner', :locals => {:organization => organization, :i => i%5+1}
class AddOrgIDtoPlans2 < ActiveRecord::Migration
def change
add_column :plans, :organization_id, :integer
end
end
@goldnuggets24
goldnuggets24 / gist:7637864
Created November 25, 2013 07:54
referred_email.rb
class ReferredEmail < Struct.new(:orig_email)
def perform
# Send to All Card Referrals except for Signups
@deals_count = Deal.all.select{|a|a.vote_score > -3 && a.organization.searchable == true}.count
referrals = (CardReferral.all.map(&:email).map(&:downcase) - CardSignup.all.map(&:email).map(&:downcase)).uniq
email_referrals = orig_email.card_referrals.map(&:email)
referrals = referrals - email_referrals
@goldnuggets24
goldnuggets24 / gist:6994976
Created October 15, 2013 17:06
gist of request
[5] pry(#<CardSignupsController>)> request
=> #<ActionDispatch::Request:0x007fd4f121a250
@env=
{"GATEWAY_INTERFACE"=>"CGI/1.1",
"PATH_INFO"=>"/card_signups/go_to_disclaimer",
"QUERY_STRING"=>"",
"REMOTE_ADDR"=>"127.0.0.1",
"REMOTE_HOST"=>"localhost",
"REQUEST_METHOD"=>"GET",
"REQUEST_URI"=>"http://localhost:3000/card_signups/go_to_disclaimer",