Rails 2.0 on Leopard

February 15, 2008 § 3 Comments

I wanted to try out some of the new Ruby on Rails 2.0 features in Leopard, so I may as well blog my notes here for future reference.

1. Update Gems

Use this if you haven’t ugpraded your system to Rails 2.0 yet.


sudo gem update --system # Update "gems" itself
sudo gem install rails # not just update, since there's new components
sudo gem uninstall actionwebservice # Get rid of SOAP; REST rules!
sudo gem update # update everything else, to help Rails 2.0 compatibility
yes | sudo gem cleanup # Remove old versions
yes | sudo gem cleanup # Twice, because of dependencies
gem list

	actionmailer (2.0.2)
	actionpack (2.0.2)
	activerecord (2.0.2)
	activeresource (2.0.2)
	activesupport (2.0.2)...
	mongrel (1.1.3)...
	rails (2.0.2)
	rake (0.8.1)...
	sqlite3-ruby (1.2.1)
	...

2. Create Project

Create the Rails project, and make sure it and Mongrel work properly.


cd ~/Developer # where I keep all my Rails projects
rails miniblog # Create new Rails hierarchy
cd !$
open http://0.0.0.0:3000 && script/server # start server and launch Safari

	=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
	=> Rails application starting on http://0.0.0.0:3000

	

3. Create Scaffold

Use [Command-T] to create a new Tab in Terminal, so the server can keep displaying output in original Tab.


cd ~/Developer/miniblog
script/generate scaffold article title:string content:text
open http://0.0.0.0:3000/articles # Will return error, since no tables

4. Add to Xcode Organizer

  • Launch Xcode
  • Click on Window -> Organizer (Ctrl-Command-O)
  • Drag ~/Developer/miniblog into Organizer window
  • Select “miniblog”
  • Under ‘Action’, choose “rake db:migrate”
  • open http://0.0.0.0:3000/articles

ActiveResource: The RESTful standard

September 27, 2007 § 1 Comment

One of the coolest if under-hyped features of RESTful Ruby on Rails is ActiveResource.  This allows you to treat any other RESTful Rails app as a database backend, providing an ActiveRecord like object model for abstracting that web service.Though changing slightly for Rails 2.0 (to use “/” instead of “;” as a parameter separator), this is becoming the de-facto standard for how to express RESTful URLs.  Work appears to be going on in both Python and Java.  There’s also a really cool JavaScript client.

Where Am I?

You are currently browsing entries tagged with rails 2.0 at iHack, therefore iBlog.