Monatsarchiv für July 2009

Ruby (on Rails) - Wirble - Pimp my IRB and Console

Monday, den 20. July 2009

Ever wanted a colored irb or script/console? Well, you should try wirble. It gives you a number of enhancements for Irb.
Some of the features are:

Tab completion
Colorized results

Installation is easy as pie:
 sudo gem install wirble

vi .irbrc
require ‘rubygems’
require ‘wirble’
# start wirble (with color)
Wirble.init
Wirble.colorize

Ruby Basics - * method arguments

Sunday, den 19. July 2009

If you have ever asked yourself what is behind arguments like *this then here is the trivial answer:
A small ruby script like this:

#!/usr/bin/env ruby
def my_method(a,b,*c)
puts “a: ” + a
puts “b: ” + b
puts “c:”
c.each { |ce| puts ce }
end
my_method(”a1″, “b2″, “c3″, “c4″, “c5″, “c6″)

Produces the following output:

a: a1
b: b2
c:
c3
c4
c5
c6

As you can see all arguments after […]

Ruby on Rails 2.3 - Nested Attributes with AJAX support

Sunday, den 12. July 2009

Introduced in Rails 2.3 nested attributes help to shorten code if you want to
edit multiple nested models within a single form.
Here the corresponding article from the rails weblog:
http://weblog.rubyonrails.org/2009/1/26/nested-model-forms
There is also a very good tutorial on nested forms from Ryan Daigle:
http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes
Right now it seems as if there is no clean way to have ajax enabled nested […]

Rails 2.3 - Test Unit - undefined method `fixtures’ (NoMethodError) - undefined method `fixtures’

Thursday, den 9. July 2009

After switching to Rails 2.3 you might receive the following error messages while executing your TestUnit tests:
undefined method `fixtures’ (NoMethodError)
and/org
undefined method `fixtures’
The solution to this is to change the class in
test/test_helper.rb
from Test::Unit::TestCase to ActiveRecord::TestCase.
You will need to apply this change to all Tests inheriting for the  Test::Unit::TestCase class.