Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (34 sloc) 1.05 KB

Requirement

Rails >= 2.3.4

Console

require 'hirb'
Hirb.enable
Country.all

Important code

build two model

./script/generate model operating_system name:string
./script/generate model country name:string code:string

create db seed

require 'open-uri'
require 'active_record/fixtures'

["Windows", "Linux", "Mac OSX"].each do |os|
  OperatingSystem.find_or_create_by_name(os)
end

Country.delete_all
open("http://openconcept.ca/sites/openconcept.ca/files/country_code_drupal_0.txt") do |countries|
  countries.read.each_line do |country|
    code, name = country.chomp.split("|")
    Country.create!(:name => name, :code => code)
  end
end

Fixtures.create_fixtures("#{Rails.root}/test/fixtures", "operation_systems")

Install Hirb

gem install cldwalker-hirb --source http://gems.github.com/

Hirb config

vi ~/.irbrc
require 'rubygems'
require 'hirb'
Hirb::View.enable

Links