Migrate a Single Database Migration

rails console
require "db/migrate/20121130134444_add_column_backorder_to_orders.rb"

Convert a Date String to Ruby Date

Date.parse '2013/1/15'


Form helper from console

From the rails console.

helper.text_field :object, :name

"<input id="object_name" name="object[name]" size="30" type="text" />"

Set default value in rails model

I like to set default values in my models. This is the method I like to use.

def after_initialize
  if new_record?
    self.upper_quantity ||= 0.0

Failed to Connect to a Master Node at Localhost:27017

Everytime my server looses power, Mongo has trouble restarting. These commands fixes the problem.

sudo rm /var/lib/mongodb/mongod.lock
sudo -u mongodb mongod -f /etc/mongodb.conf --repair
sudo service mongodb restart
Previous Next