Skip to content

Instantly share code, notes, and snippets.

View johnmcaliley's full-sized avatar

John McAliley johnmcaliley

View GitHub Profile
@johnmcaliley
johnmcaliley / migration_change_data_type.rb
Created April 11, 2011 15:26
Change the data type for a table column in Rails migration
class ChangeDataTypeForWidgetCount < ActiveRecord::Migration
def self.up
change_table :widgets do |t|
t.change :count, :float
end
end
def self.down
change_table :widgets do |t|
t.change :count, :integer
rails g devise:install
rails g devise User
rails g devise:views
rake db:migrate
@johnmcaliley
johnmcaliley / Gemfile
Created May 6, 2011 15:30
mongrel config for dev/test
#... other gems up here
group :development do
gem "mongrel", "1.2.0.pre2"
end
group :test do
gem 'cucumber'
gem 'cucumber-rails'
gem 'capybara'
@johnmcaliley
johnmcaliley / env.rb
Created May 6, 2011 15:36
capybara config for facebook auth testing
Capybara.server_port = 3001
Capybara.app_host = "localhost:3001"
Capybara.server do |app, port|
require 'rack/handler/mongrel'
Rack::Handler::Mongrel.run(app, :Port => port)
end
@johnmcaliley
johnmcaliley / your.feature
Created May 6, 2011 16:04
example of selenium scenario
@selenium
Scenario: Login with Facebook
Given I am on the "facebook" auth page #sends to facebook authorization url
And I fill in "email" with "my@email.com"
And I fill in "pass" with "mypassword"
And I press "Login"
#install from rvm site
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
#add to your bash profile
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
#source your bash profile
source .bash_profile
#make sure its working - you should see output: rvm is a function
@johnmcaliley
johnmcaliley / model.rb
Created June 9, 2011 17:38
Set invitation limit when user accepts invite
def accept_invitation!
if self.invited? && self.valid?
self.invitation_token = nil
self.invitation_limit = self.class.invitation_limit
self.save
end
end
@johnmcaliley
johnmcaliley / app.js
Created July 1, 2011 18:00
initialize express and express-resource
require('mongoose')
var express = require('express')
, resource = require('express-resource')
, app = express.createServer();
app.listen(3000);
console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
exports.index = function(req, res){
res.send('merchant index');
};
exports.new = function(req, res){
res.send('new merchant');
};
exports.create = function(req, res){
res.send('create merchant');
exports.index = function(req, res){
res.send('product index');
};
exports.new = function(req, res){
res.send('new product');
};
exports.create = function(req, res){
res.send('create product');