Posts, tutoriais e screencasts para RoR devs

Segue uma listinha de posts que achei interessante sobre Rails

Instalando Rails 3.0 e Ruby 1.9.2 no Ubuntu

Pessoas, nem de longe sou conhecedor de Ruby muito menos Rails. Estou com um plano de começar a estudar a linguagem e o framework, então depois de muito ler, o primeiro passo mesmo é fazer uma instalação para começar a brincar. Esse post é para ajudar aqueles que, como eu, ficaram perdidos entre tantos posts, blogs e forums.

Atenção: se você já manja de Ruby on Rails, fuja desse post!

Encontrei alguns tutoriais na web, explicações de como proceder. O que melhor atendeu é esse que transcrevo (literalmente) abaixo (fonte:http://toranbillups.com/blog/archive/2010/09/01/How-to-install-Rails-3.0-and-Ruby-1.9.2-on-Ubuntu):

Install RVM 1.0.1

First be sure to do a quick update before you get started.

sudo apt-get update

Next install curl and git so we can pull down ruby via rvm

sudo apt-get install curl git-core

Next you need to get the tar.gz for rvm 1.0.1

http://rvm.beginrescueend.com/releases/rvm-1.0.1.tar.gz

extract the contents and cd into the extracted directory when finished

tar xvzf rvm-1.0.1.tar.gz

Once inside the extracted directory run the installer from the command line

./install

After this is complete you need to edit your .bashrc file. First cd ~ and then Type “gedit .bashrc”. Put the following at the bottom of the file.

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

after you complete the above and save your changes, close gedit. Next close your terminal window and re-open it. Now if you type “rvm -v” you should see a valid version 1.x

Install Ruby 1.8.7

First you need to pull down a few development packages

sudo apt-get install libruby1.8 zlib1g-dev libssl-dev libreadline5-dev build-essential

Next you need to install ruby 1.8.7 through rvm

rvm install ruby-1.8.7

After this is complete you need to set ruby 1.8.7 as the default for rvm

rvm use ruby-1.8.7 --default

Install rubygems and other dev essentials

first you need to add the ubuntu-on-rails ppa repository, sometimes they have newer versions of some Ruby components.

sudo add-apt-repository ppa:ubuntu-on-rails

After you add this be sure to do another update

sudo apt-get update

Next install the essential ruby packages

sudo apt-get install ruby rubygems irb ri rdoc rake

And a few more packages, odds are you will need them anyway

sudo apt-get install build-essential ruby1.8-dev libopenssl-ruby

After all the packages above are installed, add the gem path to your global PATH, so that executables new gems can be easily called from the command line.

export PATH=/var/lib/gems/1.8/bin:$PATH

After you run the above command, close the terminal window and re-open it.

Install Sqlite3

Install the sqlite development packages

sudo apt-get install sqlite3 libsqlite3-dev

Install the sqlite gem

gem install sqlite3-ruby

Install Ruby 1.9.2

Next you need to install ruby 1.9.2 through rvm

rvm install ruby-1.9.2

After this is complete you need to set ruby 1.9.2 as the default for rvm.

rvm use ruby-1.9.2 --default

Install Rails 3.0.0

Now install rails but be sure you DON’T use sudo

gem install rails --version 3.0.0

After you have both rails 3 and ruby 1.9.2 up and running, install the sqlite gem again.

gem install sqlite3-ruby

Now you should have a fully functional rails 3 + ruby 1.9.2 development environment! You can verify this by doing a simple “ruby -v” and “rails -v” from the command line.

Funcionou corretamente, sem precisar alterar nada, no meu Ubuntu 10.10. Pelo que vi, existem pacotes que instalam todos os pacotes (Ruby, Rails, Rubygems, Sqlite, MySQL, Apache), muito semelhantes a esses LAMPs/WAMPs da vida. Não testei; havia testado para o MacOS um desses mas não funcionou :-(

Então, o pŕoximo passo é um Hello World de testes. A mais simples e didática explicação foi essa daqui (fonte: http://mentalized.net/journal/2010/02/05/hello_rails_3_world/):

So, this is a step by step tutorial to getting over the first hurdle: Creating a “hello world” application in Ruby on Rails. This should work assuming you already have Rails 3 installed and running on your system:

  1. $ rails new hello
  2. $ cd hello
  3. $ rails generate controller hello
  4. Open the file config/routes.rb. Almost at the bottom (line #57) is this line:
    # match ':controller(/:action(/:id(.:format)))'

    Remove the # in front so the line looks like:

    match ':controller(/:action(/:id(.:format)))'
  5. Create a file named index.html.erb in app/views/hello containing the text ‘Hello world’.
  6. $ rails server
  7. Navigate to http://localhost:3000/hello in your browser and be greeted by your friendly application: “Hello world”.

Testado tudo aqui no meu Ubuntu, funcionou corretamente. Espero em breve poder fazer posts mais completos do assunto.