Joined September 2012
·

Alexandr Korsak

·
·

You are shared the awesome stuff. I've just used it for my production server.

Thank you!

Update the steps:

rbenv local ree-1.8.7-2012.02
gem install bundler
git clone https://github.com/cowboyd/libv8
cd libv8
git checkout v3.16.14.3
echo "source 'https://rubygems.org'\ngem 'rubyzip', '0.9.7' \ngemspec\n" > Gemfile
gem update --system
rake checkout
curl https://raw.githubusercontent.com/sikachu/libv8/20093a74bfc77bd5ef772d8173f14e603682c373/patches/clang51/no-unused-variable.patch -o patches/my-patch
git add patches/my-patch.patch
rake install
gem install therubyracer -v '0.12.0'

As for me it's more readable like a sentence. I think it depends on a developer anyway.

Hi Richard.

Probably I have few improvements for your the first migration class. I think you should add your code under self.up method instead of using unreversible code in the change method.

Also in few months another dev can come to your team and run all migrations for some reasons instead of using schema:load and I think it would be great to define something like this before def self.up or def self.down methods:

class Coupon < ActiveRecord::Base ; end

It will skip validations for another possible things that can terminate your code.

Or instead of using create method I think it's better to use create! and wrap this code using transactions like this:

Coupon.transaction do
Coupon.findeach do |coupon|
coupon.coupon
rules.create!(
:kind => coupon.kind,
:discount => coupon.discount,
:coupon_id => coupon.id
)
end
end

If something throws exception database will rollback changes.

Achievements
392 Karma
15,546 Total ProTip Views