Read my latest article: 8 things I look for in a Ruby on Rails app (posted Thu, 06 Jul 2017 16:59:00 GMT)

One of those mornings

Posted by Tue, 17 Apr 2007 15:09:00 GMT

Well, I made it about eight months since I got my new hard drive... and today… I had to run…

sudo port -v install mysql5 +server

Why? I have to migrate some data from MySQL to PostgreSQL.

Injecting Rails into your Legacy World

Posted by Wed, 06 Sep 2006 19:26:00 GMT

Many of you know that I have an unhealthy obsession with databases… in particular legacy databases. I’m not the only one it seems. :-)

I’m hoping to compile a few stories of how Rails enthusiasts have been able to take advantage of the Ruby on Rails framework within a Legacy environment, whether that be to talk with legacy databases, web services, or a piece of cauliflower. If you have a story (good or bad) of how you used Rails with a legacy system, please email me and let’s talk. :-)

Also, I would like to announce that I have started a new google group that focuses on the topic of using Rails with legacy environments. Check out the new Rails and Legacy group.

If you’re down in California, you can see my talk, “Rails meets the Legacy World” at the Ruby on Rails Seminar, which is being hosted at the AJAXWorld Conference & Expo.

Install Ruby, Rails, and PostgreSQL on OSX

Posted by Mon, 29 May 2006 13:46:00 GMT

15 comments Latest by Manjoor Thu, 13 Jul 2006 10:00:30 GMT

WARNING: This post contains some outdated instructions. Please read Installing Ruby on Rails and PostgreSQL on OS X, Second Edition.

Our Creative Director, Allison Beckwith, picked up a new black MacBook this weekend and I had the luxury of getting it setup to model our standard setup. We all try to keep our setups fairly similar so that we don’t hit too many issues when working together on projects.

I’ll try to keep this short and to the point… because if you’re like me… you just want to start playing with Rails! ;-)

The steps I followed to get her setup like the rest of the development team at PLANET ARGON went something like this.

XCode and DarwinPorts

  • Download and install iterm (the Universal dmg)
  • Download and install XCode tools from Apple (dmg)
  • Download and install DarwinPorts (dmg)
  • Start up iterm.
In this step we are going to modify the default bash profile so that every user on the machine that uses bash will get the path for darwinports in their bash_profile.
sudo vi /etc/profile

Modify the following line to include /opt/local/bin in the PATH… save the file (see vim documentation for details)


  PATH="/bin:/sbin:/opt/local/bin:/usr/bin:/usr/sbin" 

Ruby and Rails

  • Open up a new iterm tab (apple-t)
  • Install ruby with darwinports with: sudo port install ruby rb-rubygems
  • Install Ruby on Rails and all its dependencies with: sudo gem install -y rails

PostgreSQL and Ruby libs

  • Install PostgreSQL8 with: sudo port install postgresql8
  • We need to modify the /etc/profile file again because the postgresql8 install doesn’t add programs like pg_ctl to /opt/local/bin. Change the PATH to now look like this and save.

  PATH="/bin:/sbin:/opt/local/bin:/usr/bin:/usr/sbin:/opt/local/lib/pgsql8/bin" 
  • Install the postgres gem with: sudo gem install postgres
    • Oh NO!!! You should see an error about it not finding libraries… what will we do?

  cd /opt/local/lib/ruby/gems/1.8/gems/postgres-0.7.1
  sudo ruby extconf.rb --with-pgsql-include=/opt/local/include/pgsql8 --with-pgsql-lib=/opt/local/lib/pgsql8
  sudo make && sudo make install
  # for good measure...
  sudo gem install postgres

Successfully installed postgres-0.7.1

Configure PostgreSQL for single user

In our development environments, we don’t find it necessary to keep PostgreSQL running all the time on our servers. We only want it running when we’re doing development. We also typically install it per user on a machine to keep us from needing things like usernames and passwords to connect to it from an application we’re running on the machine. Let’s setup PostgreSQL the PLANET ARGON way!

  • Open up iterm and go to your home directory
  • Init your new PostgreSQL database with: initdb -D pgdata
  • Start up PostgreSQL with: pg_ctl -D pgdata -l pgdata/psql.log start
  • Create a new database with: createdb argon_development
  • Test the new database with: psql argon_development
  • Did it load up your new database? If so, great! If not… check your steps… :-)

Test Rails + PostgreSQL

  • Navigate to a directory where you don’t mind sticking projects… mkdir development; cd development
  • Generate a new Rails application with: rails -d postgresql argon
  • Navigate to new Rails application directory. cd argon
  • Generate a new model to test with: ./script/generate model Argonista
  • Edit and save the migration that was generated ( db/migrate/001_create_argonistas.rb ) file with your favorite editor…

  class CreateArgonistas < ActiveRecord::Migration
    def self.up
      create_table :argonistas do |t|
        t.column :name, :string
        t.column :blog_url, :string
      end
    end

    def self.down
      drop_table :argonistas
    end
  end
  • Edit config/database.yml to look like the following… you’ll notice that we don’t need to supply a username or password.

  development:
    adapter: postgresql
    database: argon_development

  test:
    adapter: postgresql 
    database: argon_test

  production:
    adapter: postgresql
    database: argon_production
* Run the migration with: rake db:migrate

  $ rake db:migrate
  (in /Users/allisonbeckwith/development/argon)
  == CreateArgonistas: migrating ================================================
  -- create_table(:argonistas)
  NOTICE:  CREATE TABLE will create implicit sequence "argonistas_id_seq" for serial column "argonistas.id" 
  NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "argonistas_pkey" for table "argonistas" 
     -> 0.0399s
  == CreateArgonistas: migrated (0.0402s) =======================================
* Test your new model from console

  $ ./script/console 
  Loading development environment.
  >> a = Argonista.new
  => #<Argonista:0x24569dc @attributes={"name"=>nil, "blog_url"=>nil}, @new_record=true>
  >> a.name = 'Robby'
  => "Robby" 
  >> a.blog_url = 'http://www.robbyonrails.com'
  => "http://www.robbyonrails.com" 
  >> a.save
  => true
  >> exit
* Great, let’s go look at our database table…

  $ psql argon_development
  Welcome to psql 8.1.3, the PostgreSQL interactive terminal.

  Type:  \copyright for distribution terms
         \h for help with SQL commands
         \? for help with psql commands
         \g or terminate with semicolon to execute query
         \q to quit

  argon_development=# SELECT * FROM argonistas;
   id | name  |          blog_url           
  ----+-------+-----------------------------
    1 | Robby | http://www.robbyonrails.com
  (1 row)

There we go, we’ve setup Ruby, Rails, and PostgreSQL on a brand new Intel MacBook without breaking a sweat!

Extra Goodies

  • Subversion: sudo port install subversion
  • Lighttpd: sudo port install lighttpd
  • ImageMagick: sudo port install ImageMagick (known to take a while…)
  • GraphicsMagick: sudo port install GraphicsMagick
  • Install the rmagick gem: sudo gem install rmagick

Have fun!

Sneaking Rails through the (Legacy) system

Posted by Fri, 14 Apr 2006 22:01:00 GMT

3 comments Latest by Fabio Akita Thu, 29 Jun 2006 20:06:36 GMT

I’ll be posting stuff in the next few days about acts_as_legacy. For those not at Canada on Rails... I announced a small project that I’m going to be working on.

Acts as Legacy!

Here are my slides… up til I tried to do a live demo. ;-)


# Inventory model
class Inventory < ActiveRecord::Base
  acts_as_legacy :table_name => 'inventory',
                 :primary_key => 'prod_id',

  has_one :product, :foreign_key => self.primary_key

  column_alias :quan_in_stock, :stock

end   
Let’s try something a little different…

# SalesPerson model
class SalesPerson < ActiveRecord::Base
  acts_as_legacy :table_name => 'sales_person',
                 :primary_key 'sales_p_id',
                 :column_alias => 'sales_p_'

  validates_presence_of( :name, :email, :phone ) 
end

# usage....
SalesPerson.find( 7 ).sales_p_name
=> 'Nigel'
SalesPerson.find( 7 ).name
=> 'Nigel'

The Slideshow

...Jeremy posted his slides as well. :-)

Ruby on Rails, Refactoring Databases, and the Legacy System

Posted by Tue, 11 Apr 2006 00:11:00 GMT

1 comment Latest by Frederick Ros Wed, 12 Apr 2006 04:14:01 GMT

To avoid feeling like I have neglected my blog lately… I wanted to point out a few things.

First of all… there is a nice new book that was sitting at Powells technical bookstore just a few hours ago… and is now sitting on my desk. I read a few pages on the bus ride home today of Refactoring Database: Evolutionary Database Design. It’s a Martin Fowler signature book and you can read more by Scott W. Ambler (one of the authors) at Agile Data. So far it seems like a good book if you’re into database schemas and if your a fan of the Refactoring scene. :-)

In other news… Jeremy and I are preparing for our journey up to Vancouver, B.C. this week. Jeremy will be presenting his talk about i18n and Ruby on Rails… and I’ll be presenting my talk about using Ruby on Rails with Legacy databases. I look forward to meeting those of you who are making the trip to Canada on Rails (which is sold-out!) and if you don’t catch us there… we will also be presenting at RailsConf 2006!

If you’re going to be in Vancouver this week and would like to meet us for some drinks, hacking, or whatever… stop by on #canadaonrails (irc.freenode.net) and let us know. :-)

Related Post(s)

(more) Migrating from MySQL to PostgreSQL

Posted by Fri, 02 Dec 2005 01:59:00 GMT

Christopher Kings-Lynne is getting ready to release 1.0 of his cool project on PgFoundry called, MySQL Compatibility Functions.

What does this provide?

“A reimplemenation of as many MySQL functions as possible in PostgreSQL, as an aid to porting.”

Basically… a bunch of pg/sql functions… to account for all those mysql functions that you all love so much. :-)

For those who feel like they are stuck with MySQL… check this out.

...it’s not too late!

Next Week… I’ll discuss my progress with PostGIS and Ruby on Rails.

Older posts: 1 2 3 4 5 6