Windows in Ubuntu 8.04 with VirtualBox

I have a Windows on my machine, cause for some stuff I still need it, (MS Visio, MindMaps and couple of others application that doesn't run fine with Wine). It's a pain in the ass to always boot machine to access 2 or 3 files and stay 15 minutes on Windows.

A couple of years ago I was a big fan of VMware (old times that I virtualize ubuntu on windows), and I felt a lack of OSS on this area. So the solution it's virtualization, with VirtualBox it all comes easy!

VirtualBox, was recently bought by Sun, has 2 licenses: one commercial and one open source. I use OSE and to install it you have to follow these steps:

$ sudo apt-get install virtualbox-ose virtualbox-ose-modules-generic

Then add your current user on 'vboxusers'  group

$ sudo adduser someuser vboxusers

Go to applications > system tools > VirtualBox

Now create your Windows VM with the almost NNF (next, next,finish) wizard. It's a piece of cake!

RSpec view test for render :partial with :locals?

I was working on some rspec views tests and I've noticed that partial renderization can be tricky.

For example, if we have an index page that renders the objects list in a partial template.

In my case I was testing using a 'GivingClub' list:

describe "giving_clubs" do
  before do
    @giving_clubs = [mock_model(GivingClub)]
    assigns[:giving_clubs] = @giving_clubs
  end

  it "expect render giving clubs list" do
    template.expect_render(:partial => "/giving_clubs/list", :locals => { :giving_clubs => @giving_clubs })
    render "/giving_clubs/index"
  end
end

Do not forget the assigns before call template.expect_render. Locals works fine in this way.

HP Acquired EDS

Well another big player buying other big player. Big acquisitions in the last couple of months! For around $13 billion ($25 per share). HP said that they could double their service revenue. Well seems that market doesn't believe too much in HP since their shares are down on 6% now... 

Source: market watch

Clean Objects with find method

Hi Sirs.

An important trick on the famous ActiveRecord::Base find method.

When you are in development time of your application, and you do some query on your database query editor, is a good practice to use the limit clauses and selects just the columns you want.

In the find method we can do it with the :limit and :select arguments.

For example in our code when we try to authenticate some user we got it like:

find(:first, :conditions => [query, hash], :select => "id, email, login")

The returned object contains just the id, email and login attributes. Clean object.

Password and other attributes do not appears in the returned object =]

Simple development practice, but very important too.

See you.

Rspec quickref

Hey wanderers

Sorry for all this time frozen, the crew and I have a lot to post about, but our current assignments has kept everyone pretty busy(but that's not an excuse, so let me blow the dust off this blog).

So, just stumbled on Dave Astels (for those of you who don't know the guy, he's one of the responsible for the creation of the rspec behavior driven development framework, I'll post more specifically about it later, but you can find tons of info on the web about it) rspec QuickRef. For those of us who are using rspec a lot, this might come in handy. I know it did for me.

Just a tip this time folks, but I'll try and get some cooler tutorial next time.

Hugs to you all 

Installing RMagick on Ubuntu

Last week I was installing again rmagick on a Ubuntu server, then I discovered an very easy way to do it.

$ sudo aptitude install librmagick-ruby

Edit 10/20/08: Avoid this tutorial it doesn't work, if you wanna install rmagick use the old fashion way:

$ sudo apt-get install imagemagick
$ sudo apt-get install libmagick9-dev
$ sudo gem install rmagick
SQL Lite for Ruby On Rails

Hi all.

If your Operacional System is Ubuntu and you are using Ruby on Rails 2.0.2 you can easily use it:

$ sudo apt-get install sqlite3
$ sudo gem install sqlite3-ruby

SQLite3 does not use authentication and needs only a pointer to the database file on database yml.

development:
  adapter: sqlite3
  database: db/development.sqlite3
  timeout: 5000
test:
  adapter: sqlite3
  database: db/test.sqlite3
  timeout: 5000
production:
  adapter: sqlite3
  database: db/production.sqlite3
  timeout: 5000

When you run "rake db:create:all" on your RAILS_ROOT it creates all 3 databases.

More information about other plataforms?

Here: http://wiki.rubyonrails.org/rails/pages/HowtoUseSQLite

See you.