This file contains hidden or 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
# SQLite version 3.x | |
# gem install sqlite3 | |
# | |
# Ensure the SQLite 3 gem is defined in your Gemfile | |
# gem 'sqlite3' | |
development: | |
adapter: sqlite3 | |
database: db/development.sqlite3 | |
pool: 5 | |
timeout: 5000 |
This file contains hidden or 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
it "Visit Admin Area" do | |
@user = FactoryGirl.create(:admin) | |
login_user | |
visit "/dashboard" | |
page.should have_content("Dashboard") | |
end |
This file contains hidden or 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
1.9.2p318 :087 > c.products | |
#=> | |
[ | |
[0] #<Product:0x007fbc1ded2b38> { | |
:id => 3, | |
:name => "Racecar", | |
:description => "VRRRRRRRRRMMMMMMM", | |
:price_in_cents => 2065, | |
:active => 1, | |
:inactive_date => nil, |
This file contains hidden or 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
1.9.2p318 :088 >p = c.products.group_by { |p| p.id } | |
#=> | |
{ | |
3 => [ | |
[0] #<Product:0x007fbc1ded2b38> { | |
:id => 3, | |
:name => "Racecar", | |
:description => "VRRRRRRRRRMMMMMMM", | |
:price_in_cents => 2065, | |
:active => 1, |
This file contains hidden or 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
1.9.2p318 :119 > c.products.index_by(&:id) | |
#=> | |
{ | |
3 => #<Product:0x007fbc222615c0> { | |
:id => 3, | |
:name => "Racecar", | |
:description => "VRRRRRRRRRMMMMMMM", | |
:price_in_cents => 2065, | |
:active => 1, | |
:inactive_date => nil, |
This file contains hidden or 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
.user#info | |
%b Name: | |
%div= user.name | |
%b Information: | |
%div= user.info |
This file contains hidden or 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 NewUserEmailer | |
@queue = :emailer | |
def self.perform(user_id) | |
user = User.find(user_id) | |
mail(:to => user.email, :subject => "Welcome #{user.name}") | |
end | |
end |
This file contains hidden or 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
def next_status | |
next_status = { | |
"pending" => :cancel, | |
"shipped" => :return, | |
"paid" => :ship | |
} | |
if next_status["#{self.status.name}"] | |
send(next_status["#{self.status.name}"]) | |
end | |
self.save |
This file contains hidden or 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 BillingProcessor | |
def self.charge(amount, stripe_id) | |
Stripe::Charge.create( | |
:amount => amount, | |
:currency => "usd", | |
:customer => stripe_id | |
) | |
end | |
def self.create_customer(user_id, token) | |
user = User.find(user_id) |
This file contains hidden or 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 UsersController < ApplicationController | |
before_filter :current_user | |
before_filter :find_user, :only => [:edit, :update, :destroy, :show] | |
def show | |
end | |
def new | |
@user = User.new | |
end |
OlderNewer