This file contains 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
require 'rubygems' | |
require 'aws/s3' | |
require 'digest/md5' | |
require 'mime/types' | |
## This defines the rake task `assets:deploy`. | |
namespace :assets do | |
desc "Deploy all assets in public/**/* to S3/Cloudfront" | |
task :deploy_staging do | |
Rake::Task["assets:precompile"].execute |
This file contains 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
class SubscriptionsController < ApplicationController | |
def new | |
@plan = Plan.find(params[:plan_id]) | |
@subscription = @plan.subscriptions.build | |
end | |
def create | |
@subscription = Subscription.new(params[:subscription]) | |
if @subscription.create_customer | |
redirect_to @subscription, :notice => "Thank you for subscribing!" |
This file contains 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
class Subscription < ActiveRecord::Base | |
def create_customer | |
if !coupon.blank? && coupon_valid? | |
customer = Stripe::Customer.create( description: email, plan: plan_id, card: stripe_card_token, coupon: coupon ) | |
else | |
customer = Stripe::Customer.create( description: email, plan: plan_id, card: stripe_card_token ) | |
end | |
rescue Stripe::InvalidRequestError => e | |
logger.error "Stripe error while creating customer: #{e.message}" | |
errors.add :base, "There was a problem with your credit card. Please try again." |
This file contains 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
//= require jquery | |
//= require jquery_ujs | |
//= require jquery-ui | |
//= require google_analytics | |
//= require jquery.spin | |
//= require spin.min | |
//= require nested_form | |
//= require global | |
//= require subscriptions/subscriptions |
This file contains 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
/app/views/shared/_page_search.html.haml | |
//current placeholder, this search bar is only found on controller index pages and is directed at the individual controller | |
= simple_form_for "SEARCH", :html => {:id=>'site-page_search'} do |f| | |
= f.input :q, :label => false, :required => false, :placeholder => "#{placeholder}..." | |
// a simple solution I have come up with so that search will work on each of the index pages. | |
= form_tag request.env['REQUEST_PATH'], :method => :get, :id=>'site-page_search' do | |
= text_field_tag :search, params[:search], :placeholder => "#{placeholder}..." |
This file contains 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
Feature: Paying with Google Checkout | |
Background: | |
Given my test environment is available via an SSH tunnel | |
And the Google Checkout Sandbox is configured to callback to my test environment | |
Scenario: Paying with Google Checkout | |
Given I have some products in my cart | |
When I press "Google Checkout" | |
And I login to Google as "customer" with password "password" |
This file contains 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
class Cat < ActiveRecord::Base | |
belongs_to :owner | |
end | |
class Owner < ActiveRecord::Base | |
has_one :cat | |
scope :adoptable lambda { includes(:cat). | |
where(:cat => {:id => nil}) } | |
scope :adopted, lambda { joins(:cat) } |
This file contains 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
Factory.define :application do |factory| | |
factory.attachment :sample, "public/samples/sample.doc", "application/msword" | |
end |
This file contains 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
<script type="text/javascript"> | |
var queueBytesLoaded = 0; | |
var queueBytesTotal = 0; | |
var myQueue = null; | |
var queueChangeHandler = function(queue){ | |
// alert('Uploading Started'); | |
myQueue = queue; | |
// console.log("COLLECTION CHANGE!"); | |
var list = document.getElementById('file_todo_list'); |
This file contains 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
// This is my handler in the javascript | |
var uploadCompleteHandler = function(upload_options,event){ | |
$.ajax({ | |
url: '<%= notify_rails_of_successful_upload_path(:format => :js)%>', | |
global: false, | |
type: 'POST', | |
data: ({ | |
'authenticity_token' : '<%= form_authenticity_token %>', | |
'upload' : { | |
'file_file_name' : upload_options.FileName, |