Rails vs Grails vs Django models

Coming back to Rails after being away from some time in Django land I discovered a huge difference in how Rails, Grails and Django treats your models. In Django and Grails you can look at a model class and see all the properties it has: [python] class Organization(models.Model): name = models.CharField(max_length=255) url = models.URLField(verify_exists=False) orgtype = models.ForeignKey(OrgType) [/python] The same model class in Rails typically looks like this: [ruby] class Organization < ActiveRecord::Base belongs_to :OrgType end [/ruby]...

June 24, 2009 · Peter Krantz

Intricacies of PHP compared to Ruby

Via Tim Bray’s blog I found zestyping’s “Why PHP should never be taught”. In it he provides some interesting PHP code that will be difficult for beginners to understand. 1 $a = 0; $b = "eggs"; $c = "spam"; yields: 1 2 3 4 5 6 a == b b != c a == c a == d b != d c != d (Please note that d hasn’t been defined)....

January 1, 2008 · Peter Krantz

SimpleCrawler for your everyday web crawling needs

Over at the standards-schmandards blog I often test websites to gather statistics on specific HTML use, accessibility and other things. Each time I have written a web crawler to collect the data. In Python and Ruby this is a simple task but last time it was like a déjà vu and I decided to create a Ruby library that I could use in the future. SimpleCrawler is a Ruby gem that covers basic web crawling needs....

August 27, 2007 · Peter Krantz

Hackety Hack - The Foundation for a Revolution

Why the lucky stiff is a well known name among most Ruby developers. Many have read his Ruby programming tutorials and seen his spectacular performances (or whatever they are) at RailsConf and elsewhere. Personally, I owe him a lot for Hpricot, the liberal HTML parser (at my previous government agency Verva we used it to run the quarterly test of all public websites in Sweden). Hpricot is also the default parser for the Ruby Accessibility Analysis Kit....

July 9, 2007 · Peter Krantz

Checking for Model Classes Before Using Them in Rails Migrations

If you are using model objects in migrations (e.g. for inserting data) you should make sure that the migration works even if that model class is removed. I discovered this when setting up a new development environment and running all migrations in an empty database. Let’s say you have the following migration code: [source:ruby] class InsertCounties < ActiveRecord::Migration def self.up County.create :code => ‘10’, :name => ‘Blekinge’ County.create :code => ‘20’, :name => ‘Dalarna’ end end [/source]...

June 7, 2007 · Peter Krantz

Bringing Ruby to the .NET environment

Things are heating up in the Ruby-as-a-dotnet-language area. Martin Fowler voiced his concerns on Microsoft not being able to look at source code and therefore having trouble implementing Ruby properly. Microsoft, with John Lam in the cockpit, is implementting Ruby for the .net platform (if you have been reading my previous blog posts I predicted way back in february 2006 that John Lam would get scooped up my Microsoft:-). Ola Bini is also concerned about Microsoft not letting ther developers look at the Ruby implementation....

June 5, 2007 · Peter Krantz

Working with UTF-8 in PDF::Writer and Ruby on Rails

Googling for information on how to use PDF::Writer shows that there are many european developers frustrated with the lack of UTF-8 support in PDF::Writer. As Ruby on Rails works great with UTF-8 these days this can be a bit of an issue. Part of the problem lies in the fact that the PDF specification (at least up to 1.6) does not support UTF-8 (you can use UTF-16 if you like). I had the misfortune of plowing thorugh it a couple of years ago when developing a PDF form filler library for a customer (don’t ask)....

May 31, 2007 · Peter Krantz

New release of the Ruby Accessibility Analysis Kit and online interface

The current version has some minor bug fixes that will speed up testing. The online test interface has been updated to support direct input of markup. This is for those of you unable to install Raakt locally. This means that there is no reason to skip basic accessibility testing of whatever you are developing! To find out more on how you can integrate Raakt in your testing framework check out the Raakt wiki which now has a lot more information....

April 1, 2007 · Peter Krantz

Putting Camping in the Camping logo

Having played with the Digital Invisible Ink Toolkit (DIIT) lately it was interesting to see how big the logo file for the camping framework would become if the camping framework itself was embedded in it. The original logo file (stolen from Why’s site) is a 73 Kb PNG file. Embedding camping.rb in it creates a 101 Kb file visible to the right. Maybe this is the future of software distribution?...

March 11, 2007 · Peter Krantz

A new version of the Ruby Accessibility Analysis Kit

This is to announce that RAAKT (The Ruby Accessibility Analysis Kit) has been updated. This release includes more accessibility tests and an initial mapping of tests to the Unified Web Evaluation Methodology (UWEM). Also, thanks to Derek Perrault RAAKT now uses Hpricot to parse the HTML document. This solves the problem where the previous parser (RubyfulSoup) declared a class “Tag” that was likely to clash with your local classes in Rails....

March 3, 2007 · Peter Krantz