Skip to content

Instantly share code, notes, and snippets.

View patrickcurl's full-sized avatar

Patrick Curl patrickcurl

View GitHub Profile
# config/environments/development
# ActionMailer Config
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
# change to true to allow email to be sent during development
config.action_mailer.perform_deliveries = false
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
#config.action_mailer.default_url_options = { :host => 'your.websitedomain.com' }
config.action_mailer.smtp_settings = {
@patrickcurl
patrickcurl / gist:4370312
Created December 24, 2012 18:38
Rspec problems...
#ERROR: Failures:
# 1) users/index renders a list of users
# Failure/Error: stub_model(User,
# ActiveRecord::StatementInvalid:
# Could not find table 'users'
# ./spec/views/users/index.html.erb_spec.rb:6:in `block (2 levels) in <top (required)>'
#app/models/user.rb
# == Schema Information
@patrickcurl
patrickcurl / gist:4370441
Created December 24, 2012 19:26
rspec errors... Failure/Error: get 'create' NoMethodError: undefined method `include?' for nil:NilClass
#app/controllers/sessions.rb
def create
@login = params[:login]
#user = User.find__by_email_or_mobile(params[:login])
if @login.include?("@")
user = User.find_by_email(@login.downcase)
else
user = User.find_by_mobile(@login.gsub(/\D/, '').gsub(/^(1|0)+/,''))
@patrickcurl
patrickcurl / Lead.rb
Last active December 10, 2015 14:08
Rails associations and create method question... How do I create a new lead for user_id: 1 --and at the same time create the referral association?
class Lead < ActiveRecord::Base
attr_accessible :email
has_one :referral
has_one :user, :through => :referrals
end
@patrickcurl
patrickcurl / User.rb
Created January 16, 2013 21:32
Linking facebook/twitter via omniauth
# == Schema Information
# Schema version: 20130116180743
#
# Table name: users
#
# id :integer not null, primary key
# name :string(255)
# email :string(255)
# created_at :datetime not null
# updated_at :datetime not null
@patrickcurl
patrickcurl / User.rb
Created January 16, 2013 21:52 — forked from parndt/User.rb
# == Schema Information
# Schema version: 20130116180743
#
# Table name: users
#
# id :integer not null, primary key
# name :string(255)
# email :string(255)
# created_at :datetime not null
# updated_at :datetime not null
@patrickcurl
patrickcurl / User.rb
Last active December 11, 2015 19:08
irb(main):058:0> User.login_method("2223334444") NoMethodError: undefined method `gsub' for nil:NilClass from (irb):9:in `format_mobile' from /home/patrick/Rails/goldengoose/app/models/user.rb:29:in `login_method' from (irb):58 from /home/patrick/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start' from /hom…
#error:
# irb(main):058:0> User.login_method("2223334444")
# NoMethodError: undefined method `gsub' for nil:NilClass
# from (irb):9:in `format_mobile'
# from /home/patrick/Rails/goldengoose/app/models/user.rb:29:in `login_method'
# from (irb):58
# from /home/patrick/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
# from /home/patrick/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
# from /home/patrick/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
# from script/rails:6:in `require'
class Lead < ActiveRecord::Base
attr_accessible :first_name, :last_name, :email, :phone, :address, :city, :state, :zipcode, :referral_attributes
has_one :referral
has_one :user, :through => :referral
delegate :name, :first_name, :last_name, :email, :phone, :address, :city, :state, :zip, :to => :user, :prefix =>true
# self.per_page = 5
validates_presence_of :email
validates_uniqueness_of :email
accepts_nested_attributes_for :referral
@patrickcurl
patrickcurl / getCategories.php
Created August 1, 2013 15:53
Gathering all nodes w/ names.
$response =amazonXML('1111837295');
// function that creates xml object from amazon url
// ... $amazonXML = simplexml_load_string(file_get_contents($amazon_url));
// $amazonXML->registerXpathNamespace("xmlns", "http://webservices.amazon.com/AWSECommerceService/2011-08-01");
// return $amazonXML;
$browsenodes = $response->Items->Item->BrowseNodes->children();
var_dump($browsenodes); // see bottom.
<?xml version="1.0"?>
<ItemLookupResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2011-08-01">
<OperationRequest>
<RequestId>cd4fa414-b84c-445c-ba71-5c0132c3dfa3</RequestId>
<Arguments>
<Argument Name="Condition" Value="All"/>
<Argument Name="Operation" Value="ItemLookup"/>
<Argument Name="Service" Value="AWSECommerceService"/>
<Argument Name="ItemPage" Value="1"/>