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 'spec_helper' | |
feature 'logging in' do | |
let(:user) { create :user } | |
scenario 'with correct credentials' do | |
visit login_path | |
fill_in 'session_email', with: user.email | |
fill_in 'session_password', with: user.password | |
click_button 'Log In' |
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
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
size: 200, | |
email: '', | |
gravatarUrl: function() { | |
var email = this.get('email'), | |
size = this.get('size'); |
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
.credit-card { | |
padding: 7px 40px 7px 7px; | |
background: #FFF url('generic.png') 97% 50% no-repeat; | |
background-size: 25px 25px; | |
width: 100%; | |
} | |
input.visa { | |
background-image: url('visa.png'); | |
} |
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
$ -> | |
$('input.credit-card').payment('formatCardNumber') | |
$('input.cvc').payment('formatCardCVC') |
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
var stripe = require('stripe')('YOUR_API_KEY'); | |
exports.create = function(req, res, next) { | |
stripe.customers.create( | |
{ email: user.email, plan: 'YOUR_PLAN_ID', card: req.body.stripeToken }, | |
function(err, customer) { | |
if (err) return next(err); | |
user.customerToken = customer.id; | |
// Save your user, and redirect | |
} |
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
var userSchema = new mongoose.Schema({ | |
email: { type: String, unique: true, lowercase: true }, | |
customerToken: String | |
}); |
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 Post < ActiveRecord::Base | |
has_many :comments | |
end | |
class Comment < ActiveRecord::Base | |
belongs_to :post, counter_cache: true | |
end | |
# Migration | |
add_column :posts, :comments_count, :integer, default: 0 |
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
server { | |
listen 80; | |
root /var/www/yourdomain.com/public; | |
index index.html index.htm; | |
server_name yourdomain.com; | |
location / { | |
default_type "text/html"; |