Sep/07 24 3:23 pm
installing ruby on rails
one comment
This is the first in a series of articles about developing a web application using Ruby on Rails. In this article we’ll look at installing Rails and creating a development environment.
To give a good realistic base for web application development we’ll install Edge Rails along with a suitable database and add some good options including Globalize for international support and database sessions. This example installs Rails in a Windows environment but there’s not much difference for a Mac or Linux installation.
ruby
Get the latest version of Ruby from the Ruby programming site. A standard Windows installer is available and we’re currently using version 1.8.6.
rails
After Ruby is installed you can obtain the latest stable release of Rails as a Ruby gem.
$ gem install rails --include-dependencies
database
You should already have your choice of database installed so we won’t cover that here. We currently use Rails with either MySQL or SQLite and in the past have used other databases too. The significant point during the Rails installation is to get hold of the appropriate Ruby gem for your database. For example, if you are using MySQL:
$ gem install mysql
create your Rails application
The remainder of the installation is required to be done within each application so create your Rails application now.
$ rails demo $ cd demo
At this time remember to change the database.yml file to reflect your choice of database. For example:
defaults: &defaults adapter: mysql username: demo password: ... host: localhost encoding: utf8 development: database: demo_development <<: *defaults test: database: demo_test <<: *defaults
edge rails
Rails is evolving quickly so we believe it is advisable to be at the edge. If you don’t you could find yourself missing new features and using code which will deprecate in a future version. We prefer to fix the version of Rails within each application so that you always now at deployment that everything will work as expected. Of course, you can refresh your frozen version of Rails from time to time during development to ensure you are as close to the edge at release as possible. At the same time, we’ll generate the rdoc.
$ rake rails:freeze:edge $ rake doc:rails
database sessions
To store session data in the database…
$ rake db:sessions:create $ rake db:migrate
…and don’t forget to uncomment the line in the environment.rb file to set the session store to be :active_record_store.
globalize
As much of what we do is international, we find it easier to build i18n in right at the beginning of each application. We’ll talk about Globalize in future articles but for now it’s a good idea to get it installed.
$ ruby script/plugin install
http://svn.globalize-rails.org/svn/globalize/trunk
$ rake globalize:setup
Life at the edge does mean that sometimes you have to accept and cope with things not yet completed. Currently activeresource is part of edge rails but not included by default therefore it’s necessary to install the gem:
$ gem install activeresource --source http://gems.rubyonrails.orgAdditionally the breakpoint_server setting normally in development.rb is deprecated and should be removed.