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.Router.map(function() { | |
this.route('login'); | |
}); |
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.LoginController = Ember.Controller.extend(Ember.SimpleAuth.LoginControllerMixin); |
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 SessionsController < ApplicationController | |
def create | |
user = User.find_by_email params[:username] | |
if user && user.authenticate(params[:password]) | |
render json: { access_token: user.access_token } | |
else | |
render json: {}, status: 401 | |
end | |
end | |
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
var gulp = require('gulp'); | |
var concat = require('gulp-concat'); | |
var stylus = require('gulp-stylus'); | |
gulp.task('styles', function() { | |
gulp.src('./bower_components/bootstrap/dist/css/bootstrap.css') | |
.pipe(concat('vendor.css')) | |
.pipe(gulp.dest('./public')) | |
gulp.src('./assets/**/*.styl') |
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"; |
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
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
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
$ -> | |
$('input.credit-card').payment('formatCardNumber') | |
$('input.cvc').payment('formatCardCVC') |