Ruby on Rails 3 can be hard to get up and running, especially on Windows. That’s why I changed to Ubuntu. You can too, by running a virtual machine.
You can install and use Ubuntu on Windows using a virtual machine. Just download the latest Ubuntu and then run it on the virtual machine – pretty straightforward.
Once you have Ubuntu installed you can get the rails environment up and running. I recently found out that Heroku (my rails host of choice) like postgreSQL instead of mysql (you can use mysql but you have to link it to Amazon RDS). so I have added a second link to help you setup postgreSQL – NOTE the postgre gem didn’t work for me, but the ‘pg’ gem did (that’s right – it’s a gem called pg. It’s actually made by the creator of Ruby).
How to install rails 3 on Ubuntu 9.10 x64
Installing Ruby on Rails with Postgresql on Ubuntu Jaunty
The rest of this post is for when you have installed RVM.
RVM is perfect for the developer who wants to dabble in new versions of rails, but still be able to create/edit their ongoing older rails applications.
The reason for this post is that I happened to spend around 10 hours in a confused state trying to get this all set up on Ubuntu. There is a maze that one can easily fall into, and struggle to get out. Here are some rules to stop you falling into that maze:
To install a ruby version, say ruby 1.9.2 go:
Once rvm is installed you can go:
This will put you into ruby 1.9.1 and sets it to default. To see that it worked type in:
To change ruby to the version originally installed on your system:
To install a gem on all your ruby versions:
To install a gem on the version you are currently in:
To install a gem on a different version:
So you don’t use ‘sudo gem install’ – just ‘gem install’ (after loading your ruby environment).
Sudo apparently pulls you out of the carefully tuned rvm environment.
Install Rails 3
$ gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
$ gem list
# If you get an error when just typing in 'gem install rails', try this:
$ rvm 1.9.2 gem install rails
So your gems will be different for each ruby version. This is because if they all use the same gems – things go wrong.
Note – Rails asset versioning causing me problems in Ubuntu:
When editing CSS in rails, I found that when I made edits and refreshed the page, my rails app would suddenly not recognise any of my css files. This is because of the timestamps rails puts on the end of the files – for some reason Apache is not reloading the new, updated files.
Fix:
Turns out it was WeBrick. ‘gem install mongrel’ and then ‘script/server mongrel’ makes it work.
Tagged: rails 3, Ruby on Rails, set up rails ubuntu, ubuntu, ubuntu rails