NewMonarch (owner)

Revisions

gist: 99156 Download_button fork
public
Public Clone URL: git://gist.github.com/99156.git
Embed All Files: show embed
migration.rb #
1
2
3
4
5
6
7
8
9
10
class AddSecurityStringToOrder < ActiveRecord::Migration
  def self.up
    add_column :orders, :security_string, :string
  end
 
  def self.down
    remove_column :orders, :security_string
  end
end
 
order.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
...
 
before_create :set_security_string
 
def set_security_string
  self.security_string = Digest::SHA1.hexdigest("#{Time.now}#{rand.to_s}")[0..15]
end
 
def to_param
  security_string
end
 
...