Monthly Archives: August 2012

Quick and usefull git commands

#Log of all the reference HEAD
$ git reflog

#Go to a previous head
$ git reset –hard HEAD@{0}.

# Check what lines were added?
git log –oneline -p

# Check how many insertions were made
git log –oneline –stat

# Display a visual representation of your git map
git log –oneline –graph

Rake Task Omniauth Identity + carrierwave

I often use rake db:populate in development mode to populate my database with random data. It’s a useful too to test your website and see how it would look like when you have a lot of users. It’s also extremely useful for testing paginations. On Railsview.com I build a script that auto generate random user using the Omniauth Identity gem and then generate random user’s theme that each have an image using the carrierwave gem.

namespace :db do
require ‘Faker’
require ‘omniauth’
desc “Fill database with sample data”
task :populate => :environment do
Rake::Task[‘db:reset’].invoke
make_users
end
end

def make_users

20.times do |n|
name = Faker::Name.name
email = “test-#{n+1}@test.com”
password = “password”

# CREATE USERS: Populate the database with random users
Identity.create! do |user|
user.name = name
user.email = email
user.password_digest = BCrypt::Password.create(password)
end
Continue reading

How I set up Paypal Adaptive Payment for Railsview.com

Before you start, you need to create a developer account on https://www.x.com/ and have set u tow user in your paypal sandbox account. One for the merchant, and one for the seller. These account will be use to test this payment here. here railsview_paypal_account@gmail.com will be the sample email I will use to represent the merchant and author_paypal_account@gmail.com is the sample email I will use to represent the seller. This payment model is a chained payment which mean that there will be more than one recipient for the amount of the sale.

 In the controller:

class OrdersController < ApplicationController
before_filter :assigns_gateway
include OrderHelper

include ActiveMerchant::Billing::Integrations

Continue reading