Skip to content

Instantly share code, notes, and snippets.

View jhancock's full-sized avatar

Jon Hancock jhancock

  • http://shellshadow.com
  • Wellington, New Zealand
View GitHub Profile
> merb -i
Loading init file from /Users/jhancock/src/ssmerb.git/config/init.rb
Loading /Users/jhancock/src/ssmerb.git/config/environments/development.rb
~ Connecting to database...
~ Parent pid: 3922
~ Compiling routes...
irb: warn: can't alias context from irb_context.
>>
def activate_post(user, _submit_activate = nil, _submit_cancel = nil)
@page_title = 'Activate Account'
if _submit_cancel
message[:notice] = "Activation cancelled"
redirect(url(:home), :message => message)
elsif _submit_activate # activate action
@user = User.new(user)
if user[:password] != user[:password_confirmed]
@user.errors.add(:password, "passwords do not match")
# do not want to redisplay these values
# FIXME - if I am not logged in an I get redirected to login, upon success, the email_unconfirmed_code which was passed to the original request is lost
def confirm_email_get(email_unconfirmed_code = nil)
@page_title = "Confirm new email"
@email_unconfirmed_code = email_unconfirmed_code
render(:confirm_email)
end
def login_user(user)
# FIXME The following line is not the "public" way to trigger auth'ing a user. It probably should be though ;). Currently, its not clear there is a public way to trigger the process through a controller action that is not part of the login process.
session.user = user
# FIXME The following line should be triggered by an after hook in merb-auth. Assumes the prior line is doing the right thing.
session[:display_name] = user.display_name
end
# Authenticates a user by their email and cleartext password. Returns a User or nil.
def self.authenticate(email, password)
if user = self.activated.first(:email => email)
if validate_password(password, user.password_hash, user.password_salt)
return user
end
end
false
end
require 'rubygems'
require 'mongo'
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT
puts "Connecting to #{host}:#{port}"
db = XGen::Mongo::Driver::Mongo.new(host, port).db('jon')
coll = db.collection('test')
require 'rubygems'
require 'mongo'
require 'pp'
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT
puts "Connecting to #{host}:#{port}"
db = XGen::Mongo::Driver::Mongo.new(host, port).db('jon')
coll = db.collection('test')
require 'rubygems'
require 'mongo'
require 'pp'
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT
puts "Connecting to #{host}:#{port}"
db = XGen::Mongo::Driver::Mongo.new(host, port).db('jon')
coll = db.collection('test')
require 'rubygems'
require 'mongo'
require 'pp'
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT
puts "Connecting to #{host}:#{port}"
db = XGen::Mongo::Driver::Mongo.new(host, port).db('jon')
coll = db.collection('test')
require 'rubygems'
require 'mongo'
require 'pp'
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT
puts "Connecting to #{host}:#{port}"
db = XGen::Mongo::Driver::Mongo.new(host, port).db('jon')
coll = db.collection('test')