Rails 3: Rack Middleware »
Created at: 18.02.2010 21:14, source: OnRails.org, tagged: Ruby on Rails Rails3
I’m watching the Rails Online Conference, February 2010 Exploring Rails 3 and really like how they setup the rack middleware.
...From the slides.
Rack Middleware
http://github.com/rack/rack/tree/master/lib/rack
Content Modifying
Rack::Chunked Rack::ContentLength Rack::ConditionalGet Rack::ContentType Rack::Deflater Rack::ETag Rack::Head Rack::MethodOverride Rack::Runtime Rack::Sendfile Rack::ShowStatus
Behavioral
Rack::CommonLogger Rack::Lint Rack::Lock Rack::Reloader
Routing
Rack::Cascade Rack::Recursive Rack::Static Rack::URLMap
Rack::Contrib
http://github.com/rack/rack-contrib
Rack::AcceptFormat Rack::Access Rack::Backstage Rack::Callbacks Rack::Config Rack::Cookies Rack::CSSHTTPRequest Rack::Deflect Rack::Evil Rack::HostMeta Rack::JSONP Rack::LighttpdScriptNameFix Rack::Locale Rack::MailExceptions Rack::NestedParams Rack::NotFound Rack::ProcTitle Rack::Profiler Rack::ResponseCache Rack::ResponseHeaders Rack::RelativeRedirect Rack::Signals Rack::SimpleEndpoint Rack::TimeZone
Coderack.org
Check also out http://coderack.org ...99 pieces of Rack Middleware
RailsGuide: Rails On Rack
http://guides.rubyonrails.org/rails_on_rack.html
more »
Time.onrails.org is closing! »
Created at: 18.02.2010 05:15, source: OnRails.org, tagged: Ruby on Rails Time.OnRails.org
I just send an email to thousands of users to notify them that time.onrails.org is closing down. I don’t think many of these users are active but just in case I wanted everyone to be able to get their data out of the system if so they wished.
I will turn down the service on March 17th at 9pm.
Now why in the hell would I close this service. In brief I created it for myself on the plane to RubyConf 2005, thought it was cool and opened it to the public in April 2006. I haven’t updated the code much since many years and just don’t have the time to add new features, and trust me Rails code from 2005 looks slightly different than nowadays Rails code.
For posterity here is the “official” announcement blog entry of the creation of the service:
April 13, 2006 – LAUNCH time.onrails.org, time tracking made simple!
And here are few more articles related to time.onrails.org.
Here is part of the email I send to the users:
Time.onrails.org is closing down March 17th 2010 at 9pm Mountain time.
You can export your time entry for each project by clicking on the export buttons at the bottom of each project page or you can export your full account by just login and then go to this url:
http://time.onrails.org/export/xml/user
This will export each of the projects will all sections including the notes.
Please start transitioning to a new service now.
As a replacement service I would suggest harvest (http://www.getharvest.com/) which offers a free plan which allows for 2 projects, 4 clients, unlimited invoicing for 1 user absolutely FREE.
Thank you to all the users over the years I hope you enjoyed this free service. Time.onrails.org enjoyed thousands of users and I received many nice complimenting emails for the service over the years. The main reason that I close this service is that I am starting to use harvestapp for my own time tracking. I wrote time.onrails.org back in 2005 just for fun and thought it could be useful to others. It fulfilled my needs of keeping track of time for the various customer projects I worked on over the last few years.
Since we moved to slicehost it was very stable and I just have good things to say about slicehost, they are just great. Recently one of the slice time.onrails.org was running on had issues and got moved twice over two days. Again slicehost was on top of that situation and I just sat back and they did all the work. But this also reminded me that I cannot just keep the service running without giving it the time and effort it deserves and just now I don’t have that time as I am working on other projects, such as http://appsden.com.
So I went on the search for a replacement service and looked at many out there. And Harvest just added the timestamp feature, which is exactly how I track time, their app is more fleshed out than time.onrails.org, so I decided to move over to use their services.
The great news is while I tweeted about my move to Harvest, Doug, which I knew from his time in Denver mentioned that he now works for Harvest. So he put me in contact with the cofounder and I asked him if they could get some deal for my current users, and they where very responsive and create a special promo code. Thanks for that and I hope you try and enjoy their services. Just for disclaimer I didn’t ask for any monetization or anything for referring you to Harvest, the idea was just to have an alternate offering in case you needed one. But they offered me a free Solo plan, so hey, at least I got that out of this whole ordeal.
Please don’t hesitate to contact me for any question at daniel@onrails.org.
Thank you again for having tried out or being a user of time.onrails.org over all these years.
Kind regards, Daniel Wanja
more »
Installing Ruby on Rails, Passenger, PostgreSQL, MySQL, Oh My Zsh on Snow Leopard, Fourth Edition »
Created at: 08.02.2010 21:14, source: Robby on Rails, tagged: Business Ruby on Rails ruby programming PostgreSQL PLANET ARGON rubyonrails github ohmyzsh zsh PostgreSQL mysql rails ruby xcode snowleopard osx guide
Welcome to what seems like my tenth installment (actually, it’s the fourth) of showing you how I setup my development environment on a fresh OSX install. In this case, I’m actually getting a MacBook setup for a new employee with Snow Leopard.
Over the years, I’ve evolved these following steps and they’ve helped our team maintain a consistent and stable envirnment for Ruby on Rails development. I know that there are a few other ways to approaching this and I’m sure you’ll get similar results, but this approach has allowed me to maintain a hassle-free setup for the last five years.
As with all things… your milage may vary.
Phase One
During this initial phase, we’re going to install the primary dependencies and setup our environment.
XCode
The first thing that you’ll need to do is install XCode, which almost everything depends upon as this will install developer-friendly tools for you. Apple has been kind enough to ship this on your Snow Leopard DVD.

Go ahead and install XCode from the Optional Installs folder.

(might require a reboot)
You can also download it online.
MacPorts
Now we’ll install MacPorts, which the web site describes itself as, “an open-source community initiative to design an easy-to-use system for compiling, installing, and upgrading either command-line, X11 or Aqua based open-source software on the Mac OS X operating system.”
As I’ve said in past versions of this guide, this tool is about to become one of the most important tools on your operating system. It’ll be used time and time again to maintain your libraries and many of the Unix tools that you’ll be using. If you’re from the Linux or BSD world, you are likely familiar with similar tools… such as: apt-get, port, and yum.
You’ll want to download the latest stable version from http://www.macports.org/. Once downloaded, you can install it.

Once this is installed, you’ll be able to use the port command from your console.
Wget
Let’s test out your MacPorts install by installing a useful tool called wget, which we’ll use to install oh-my-zsh.
sudo port install wget
Git and Subversion
Every development environment should have some source code management tools available. We’ll install both of these with one command.
sudo port install git-core +svn
This will install git and subversion.
oh-my-zsh
Oh My Zsh is the most amazing thing to happen to shells since… well since I said so. It’s one of my open source projects that I encourage you to give a whirl.
wget http://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
That’s it. The next time you open up your terminal, you’ll be running zsh with a bunch of stuff available. For more information, visit http://github.com/robbyrussell/oh-my-zsh.
Terminal theme (optional)
I never understood why the icon for Terminal has a black background but when you start it up the default theme is black on white.

versus

Anyhow, I’m a fan of the the dark background. To change this, open up preferences in Terminal. Select Pro, then click on the Default window so that this sticks around.

Let’s now open up a new Terminal window..
You should be looking at something like this:

Much better… let’s continue.
Phase Two
We’re now going to start installing everything we need to get this running.
Ruby 1.8.7.x
First up, Ruby.
Snow Leopard includes Ruby and Rails already installed, but we’re going to back these up for a rainy day. Just issue these commands:
$ sudo su -
Password:
:~ root# mv /usr/bin/ruby /usr/bin/ruby.orig
:~ root# mv /usr/bin/gem /usr/bin/gem.orig
:~ root# mv /usr/bin/rails /usr/bin/rails.orig
:~ root# logout

Now we’ll go ahead and install a fresh copy of Ruby and RubyGems via MacPorts.
sudo port install ruby rb-rubygems
You should now see something like this for a bit…

Let’s watch a video about bumble bees.
When it finishes installing, you should check that Ruby is available to you and installed in /opt/local/bin.

We’ll also take a second to create a symlink for this as some tools seem to rely on /usr/bin/ruby being there.
sudo ln -s /opt/local/bin/ruby /usr/bin/ruby
Great, let’s move on.
Passenger (mod_rails)
Now that we have Ruby installed, we’re going to take a quick detour to setup Passenger with the Apache server already available on your machine. I’ve been a big fan of using Passenger for your development for over a year now.
sudo gem install passenger
Once the gem is finished installing, you’ll need to install the apache2 module with the following command:
It’ll ask you to continue by pressing Enter. At this point, it’ll check that you have all the necessary dependencies and then compile everything needed for Apache2.

Now I’ll force you to watch a highlights reel of Fernando Torres… the best striker in the world!
The passenger install will then show you this output, which you’ll want to stop and read for a moment and highlight the following:

Then using vi or emacs, you’ll want to create a new file with the following content:
vi /etc/apache2/other/passenger.conf
Then paste in the following (what you highlighted and copied above.)
LoadModule passenger_module /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.9/ext/apache2/mod_passenger.so
PassengerRoot /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.9
PassengerRuby /opt/local/bin/ruby
You’ll also want to include the following below what you just pasted.
# Set the default environment to development
RailsEnv development
# Which directory do you want Apache to be able to look into for projects?
<Directory "/Users/ryangensel/development">
Order allow,deny
Allow from all
</Directory>
You’ll want to quickly start up your web sharing, which will start Apache2 up via your System Preferences.


Simple enough… moving forward.
Passenger Pref Pane
To make things as simple as possible, I’d encourage you to install the Passenger Preference Pane (view this post for a download).

Development directory
I have a directory named development/ in my home directory, which is where I end up storing all of my projects. This should match whatever you put above in the apache configuration (<Directory "/Users/ryangensel/development">).
mkdir development; cd development;
Installing Ruby on Rails via RubyGems
Now we’ll use RubyGems to install the latest version of Ruby on Rails (and all of it’s dependencies).
sudo gem install rails

While this is installing, you can watch a video from my old band that ended around the time that business started picking up for Planet Argon.
Great, let’s test out the install of Rails…
Test Rails and Passenger
In your development directory, let’s quickly a new Rails app…
rails testapp
This will generate a new Rails application in a testapp/ directory.
Now open up the Passenger Preferences Pane and add this directory as a new application.


Press Apply…
You should now fire up your browser of choice and head to http://testapp.local. If all has worked, you’ll see a, “Welcome aboard” screen from the Ruby on Rails application.

Assuming that this worked for you, let’s take a quick break to make some tea…
Phase Three
In this last phase, we’re going to install a few database servers and corresponding rubygems so that you can get to work.
PostgreSQL
At Planet Argon, we build our web applications on top of PostgreSQL. I’ve been a long-time advocate of it and hope you consider using it yourself.
At this point in time, the current stable version of PostgreSQL via MacPorts is 8.4.x. Let’s install that now…
sudo port install postgresql84 postgresql84-server
Once this finishes compiling, you’ll need to run the following commands to setup a new PostgreSQL database.
sudo mkdir -p /opt/local/var/db/postgresql84/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql84/defaultdb
sudo su postgres -c '/opt/local/lib/postgresql84/bin/initdb -D /opt/local/var/db/postgresql84/defaultdb'
Assuming that you want PostgreSQL to always be running, you can run:
sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql84-server.plist
...and to start it right now, run:
sudo launchctl start org.macports.postgresql84-server
Before you can start using it, we’ll need to make sure that the PostgreSQL executables are available in your shell path. Since you’re now using oh-my-zsh, you’ll want to edit ~/.zshrc with your favorite editor.
vi ~/.zshrc
Just append this to export PATH= line in the file.
:/opt/local/lib/postgresql84/bin
Your PATH might look something like the following now:
@# Customize to your needs… export PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/lib/postgresql84/bin@
Setup database user
To setup a new database (with superuser credentials), just run:
createuser --superuser ryangensel -U postgres
We’ll now test creating a database:
createdb test_db
Let’s test that we can access it…
➜ ~ psql test_db
psql (8.4.2)
Type "help" for help.
test_db=# \q
Great, let’s drop it now.
➜ ~ dropdb test_db
➜ ~ psql test_db
psql: FATAL: database "test_db" does not exist
➜ ~
Okay, we’ll now install the library that will allow Ruby to talk to PostgreSQL.
Just run: sudo gem install pg

Voila… let’s move on to the inferior database…
MySQL
We’re going to run through the installation of MySQL really quickly because you might need it.
sudo port install mysql5 mysql5-server
This took ages on my machine… so let’s watch a video.
We’ll now setup the database and make sure it starts on system boot.
sudo -u _mysql mysql_install_db5
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
sudo launchctl start org.macports.mysql5
Let’s test that we can create a database now (and that it’s running.)
➜ ~ mysql5 -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.43 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database test1;
Query OK, 1 row affected (0.00 sec)
mysql> \q
Great, we’ll now install the library that will allow Ruby to talk to MySQL.
sudo gem install mysql -- --with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config
That should be it!
Phase Four, next steps
Okay… so we’ve installed XCode, MacPorts, Ruby, Rails, PostgreSQL, MySQL… and I’ve also got you to switch your default terminal shell from bash to zsh. You might take a look over the available themes for Oh My Zsh so that you can personalize your terminal experience even further.
You also now have a handful of gems installed as you can see with gem list.

Closing thoughts…
This is the fourth version of this guide and I’ve appreciated the hundreds of comments, questions, and emails that I have received… let’s not forget all those beers that people buy me when I’m at conferences. :-)
I hope you have found some of this useful. If you have any problems and/or questions, don’t hesitate to post them in the comments section below.
more »
Rails 3.0 Beta: 36 Links and Resources To Get You Going »
Created at: 06.02.2010 01:27, source: Ruby Inside, tagged: Compilation Posts Reference Ruby on Rails on rails ruby
Whenever something's a really "big deal" in the Ruby world, we cover it - even if it makes more sense on Rails Inside (which is now switching to a user contributions model). Given that, we've gone through all the latest and greatest Rails 3.0 related links and put together a ton of them to help you on your way with the recently released Rails 3.0 beta. Enjoy!
Getting Started / Must Reads
Rails 3.0 Release Notes - An epic amount of documentation from the Rails Guides project. If you're already pretty familiar with Rails 2.x and just want to know what's new and updated, this is the place to look first. If you read this whole page, you'll get a good feel for what you need to pick up next.
The Path to Rails 3: Greenfielding New Apps With The Rails 3 Beta - Jeremy McAnally has written an awesome practical guide to setting up Rails 3 beta and creating a new app from scratch. Of note is his coverage of the new app generator and configuration system. He gets you as far as finishing off some scaffolding and even adding some tests.
Rails 3 Introduction - A two week old post by Jeremy McAnally that provides a high level introduction to Rails 3. What is it, why is it? And so forth. He demonstrates how Rails has moved from a monolithic, packaged "deal" to an ecosystem of more loosely coupled libraries that work together.
How To Install Rails 3.0 Beta - Our own guide to getting Rails 3.0 up and running. Sure, it's only two lines, but we beat the official Rails blog by 4 minutes on this *g*
RailsPlugins.org - A new Rails plugins directory.
Upgrading & Preparing Your Existing Apps
Geoffrey Grosenbach's Rails 3 Upgrade Screencast - Geoffrey Grosenbach (of PeepCode fame) has put together a free screencast demonstrating how to migrate a Rails 2.x app to Rails 3.0. A very high quality production.
rails_upgrade Plugin - An official plugin that runs checks on your Rails 2.x application and notifies you of obvious things that need to be changed for Rails 3.0 usage. It's unlikely to give you full coverage of every issue, but as a general overview it's pretty cool.
5 Things You Can Do Today to Make Your App Ready for Rails 3 - A short post that recommends you start to use Bundler, use inherited_resources, use rails_xss, use more named scopes, and change your references to certain constants.. all in your existing app so it's easier to upgrade to 3.0 later.
Rails 3 Ready Plugins - If you're heavily dependant on a certain plugin, see if it's already on the confirmed Yes/No list of plugins that do/don't work with Rails 3.0. It's still a short list so if you're a plugin maintainer, be sure to add your plugin if you know either way!
How to upgrade plugins to Rails 3.0 - A fresh and code heavy look at how to make some basic changes to upgrade a Rails 2.x plugin to Rails 3.x standards!
Rails 3.0 Libraries and Components
Active Record Query Interface 3.0 - Pratik Naik demonstrates ActiveRecord's finder methods and shows how a number of techniques are being deprecated in Rails 3.1. In essence, queries move away from a single find* method packed with arguments to a chain of methods performed upon a simpler find. There are lots of good code examples in here! Why Arel? is also a great introduction to this topic and shows the motivation and theory behind the "relational algebra" in ActiveRecord 3.
ActiveModel: Make Any Ruby Object Feel Like ActiveRecord - Yehuda Katz introduces us to the new ActiveModel system in Rails 3.0 by showing us how we can use it to make any Ruby class feel like an old-school ActiveRecord model. All of this is a result of splitting out the model and database behavior from ActiveRecord into separate libraries, thus removing the necessity for a database backend (or nasty hacks).
Render Options in Rails 3 - Yehuda Katz looks at how Rails 3's rendering pipeline works and demonstrates how to add a custom PDF renderer to it.
Generic Actions in Rails 3 - Yehuda Katz (again!) shows us how to create clever "generic actions" to do things like redirections direct from the routes file and generic template rendering. It's also worth a look for the discussion on route matcher changes.
Making Generators for Rails 3 With Thor - David Trasbo demonstrates how to use Thor (essentially a better Rake - sorta) to produce new generators for Rails 3 projects. This is a code heavy walkthrough. There's more on generators here.
New ActionMailer API in Rails 3.0 - Mikel Lindsaar got stuck in and built a much improved mail library for Ruby. This new "mail" library is now the new foundation of ActionMailer in Rails 3.0. In this article, Mikel gives a tour of how it works and how you can put together mails quickly and easily from within Rails 3.0 apps.
Validations in Rails 3.0 - Mikel Lindsaar shows how validations have changed in Rails 3.0. Instead of being a part of ActiveRecord, they're now in ActiveModel and can be used on non-DB related objects too! The old school validation methods are still around but now there are some other, cleaner ways to accomplish the same things.. Mikel shows you how.
Rails3_DataMapper - A library that gets DataMapper working on Rails 3. It was updated just yesterday and people have been recommending it on Twitter. If you're a DataMapper user, check it out! Update: There's now a tutorial on getting DataMapper running on Rails 3 beta!
The Rails Module - Nick Quaranto looks at how constants like RAILS_ROOT, RAILS_ENV and RAILS_DEFAULT_LOGGER have been deprecated in favor of accessing methods stored in the global Rails module (e.g.: Rails.root, Rails.env, Rails.logger).
Rails 3 I18N Changes - José Valim looks at some internationalization (i18n) changes in Rails 3.0 over 2.x - along with basic examples.
Insights
A Retrospective - Rails 3 core team member Yehuda Katz looks back at the past year and analyzes the key changes. This is worth reading if you want a softer, more thoughtful, higher level view than the release notes provide.
My 5 Favorite Things About Rails 3 - It's a few months old, but Yehuda Katz takes a look at some of the sticking points of Rails 2.x and shows how Rails 3 provides significant improvements.
Misc
Webbynode Gets Rails 3 Support for Rapid Deployment - Hosting company Webbynode shows how you can deploy a Rails 3.0 app to their VPS system with just a single command line entry. It's a bit like Heroku but more powerful and customizable. Of course, you have to pay for the VPS, but hey :-) It's also demonstrated how you can run a Rails and PHP app side by side on the same system.
How to Install Rails 3.0 Beta on Ubuntu Linux - An Ubuntu-specific guide to setting up a basic Ruby 1.9 and Rails 3.0 beta stack.
Let Your SQL Growl in Rails 3.0 - Gavin Stark demonstrates how he tweaked Rails 3.0 to put out Growl notifications for all SQL queries performed by ActiveRecord. Cute trick.
Exploring Rails 3 Free Online Conference - O'Reilly and RailsConf are putting on a free two hour online conference that features Yehuda Katz, Gregg Pollack, Jeremy Kemper and Ryan Tomayko talking about different parts of the Rails 3.0 ecosystem. It takes place on February 18, 2010.
Signed and Permanent Cookies in Rails 3 - Pratik Naik demonstrates how to set "permanent" cookies in Rails 3.0, more easily than in previous versions, all thanks to a new cookies.permanent object.
Extending Rails 3 Video - Yehuda Katz in an hour long talk demonstrating how to extend Rails 3.0.
New Rails Logos - Wanna use a Rails logo somewhere without obvious licensing or trademark issues? Check out our little contest/brewing pot of public domain logos over at Rails Inside!
How to Build Sinatra on Rails 3 - Yehuda Katz gives a code heavy demonstration of how to get a basic Sinatra application working within a Rails 3 app.
Unobtrusive JavaScript in Rails 3 - A very old post looking at some of the changes being made to JavaScript helpers in Rails 3.0.
Changes in Rails 3.0 for Agile Web Development with Rails Edition 3 - The Pragmatic Programmers are keeping a page with changes necessary for the popular AWDWR book to keep it working with Rails 3. Good to look at it if you're learning from this book!
Rails 3 App Generator Script - Want to get a complete, scaffolded Rails 3 app up in seconds? This script will get you on your way.
MooTools Driver for Rails 3 Helpers - Rails 3 is now JavaScript framework agnostic, and if you want to use MooTools, here's some info on how to go about it.
North Korean Rails 3.0 Launch Party - Everyone's in on the festivities!
NEW! Bundle Me Some Rails - A walk through using the new Gem bundler with Rails 3.0 by Mikel Lindsaar.
Another Rails 3 Link List - Michael Bumann started to keep a list of Rails 3.0 links a few days ago, so there might be others not covered here. Just found another one by Melvin Ram too.
Logo at top of post courtesy of Dylan Clendenin. See more new, unofficial Rails logos and/or submit your own!
[news] @peterc here! My next "big thing" is a new site called coder.io. If you're into technologies like Ruby, Git, Python, the iPhone, MySQL, JavaScript, Clojure, etc, you might want to get on the coming soon list for some eventual freebies/bonuses along with exclusive early access. Thanks!
more »
Rails 3.0 Beta/Prerelease Available Now and How To Install It »
Created at: 05.02.2010 05:29, source: Ruby Inside, tagged: Ruby on Rails on rails ruby
Today, Rails core member Jeremy Kemper dropped the words that lots of ardent Rails developers have been waiting for: "Rails 3 beta is LIVE." It's true! Rails 3.0's first approved beta/pre-release version is now live and ready for you to install.

Unfortunately, the installation process isn't as easy as Jeremy explains. RubyGems doesn't support the installation of prerequisites on pre-release gems, so you need to install them all manually. I think I have some instructions to cover that (works on 1.8.7 and 1.9.1):
gem install i18n tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler
# remember to prefix with "sudo" if your environment needs that
And then, finally:
gem install rails --pre
Worth reading next is a retrospective and summary of the work done for Rails 3.0 so far by Yehuda Katz.
[news] @peterc here! My next "big thing" is a new site called coder.io. If you're into technologies like Ruby, Git, Python, the iPhone, MySQL, JavaScript, Clojure, etc, you might want to get on the coming soon list for some eventual freebies/bonuses along with exclusive early access. Thanks!
more »
