Archive for July, 2006


Custom Rails ActiveRecord Messages

Jul 22, 2006 Author: admin | Filed under: Blog, Programming

Ruby On RailsWhile using Rails in my projects I’ve came up with the need to display error messages in my native language, Portuguese.
So following my last plugin on plural rules in Rails models, I’ll now quickly explain how to add custom messages to any Rails application.

Quite simply create a file called messages.rb in your /config directory (or anywhere you want) and write the following:

module ActiveRecord
class Errors
@@default_error_messages = {
:inclusion => “não está contido na lista”,
:exclusion => “está reservado”,
:invalid => “é invalido”,
:confirmation => “é diferente da confirmação”,
:accepted => “deve ser aceito”,
:empty => “não pode estar vazio”,
:blank => “não pode estar em branco”,
:too_long => “é muito longo (no máximo %d caracteres)”,
:too_short => “é muito curto (o mínimo são %d caracteres)”,
:wrong_length => “tem comprimento errado (só %d caracteres)”,
:taken => “já está a ser utilizado”,
:not_a_number => “não é um número”
}
end
end

All ActiveRecord messages are overwritten, now we just need to tell our app to call the file with the code, go to your /config/environment.rb and insert the following line:

require “#{RAILS_ROOT}/app/config/messages”

That should do the trick. Manik Juneja, a Technopreneur and blogger from Delhi explained in his blog how to further customize your messages, head down to his blog for more detailed explanation.

On another note, I’ll be announcing a new Ruby on Rails project soon. :)
I’ve had some problems with the site and all the content was deleted so during the weekend I’m going to try my best to rewrite everything.

BarCamp Portugal

Jul 19, 2006 Author: admin | Filed under: Blog, Other, Web

BarCamp PortugalNext September be ready to dedicate 2 days for BarCamp Portugal. The event which can be descrived as “an ad-hoc un-conference born from the desire for people to share and learn in an open environment. It’s an intense event with discussions, demos and interaction from attendees” takes place 2-3 Sept in Coimbra and will focus on Web 2.0, Innovation, Demos and other topics.

There’s alot of people registered already, so go to the BarCamp official page to know more details about some of the presentations or take a look at the rules of BarCamp here.
The organization will be taken care by WeBreakStuff, a portuguese company which focus on building web applications that play a role on people’s lives. They participated recently in Rails Day 2006 too.

It’s a great opportunity to exchange knowledge with other people on many subjects, make contacts, socialize and enjoy the great sunny weather from Portugal. Be sure not to miss this great event. :)

Belle and Sebastian Concert

Jul 18, 2006 Author: admin | Filed under: Blog, Music

Belle and SebastianBelle and Sebastian played last night at the “Coliseu dos Recreios” in Lisbon, Portugal.

It was a fantastic concert with many songs from their new album - The Life Pursuit - which is in my opinion one of their best, with excellent melodies and great lyrics, taking alot of inspiration from the 70’s.

There was also time for some songs from previous albums, like “The Boy with the Arab Strap” which is also a terrific album. In overall it was a very good night with a great environment and with all their great songs which make you smile in the end.

Too bad it was monday, I’ll have to go to work all sleepy today.

New theme almost done

Jul 15, 2006 Author: admin | Filed under: Blog, Other, design

Pfew, after a afternoon of extreme heat (reaching over 30 degrees) around these parts of Portugal, i’ve almost finished the work on the new theme for this site.

Alot of the previous elements and colours were ported but there’s still work to be done in various sections. As a bonus the portfolio section is reopen but it needs some serious remaking. The theme is based on the Hemingway wordpress theme with alot of tweaking from myself and help from the discussion forums.

I still need to sort the problems with the tags, find out what’s wrong with other minor details and figure out a clean way to maintain the portfolio section, perhaps in the next day or two. Good weekend.

[update 1] fixed problem with 1024×768 screen resolution. I temporarily disabled the contact and feed button so I guess I’ll have to review the menu. The image with the glasses (png) should be transparent but doesn’t look that way, I’ll have to check out why.

A new way to solve problems, do it like Zidane…

Jul 14, 2006 Author: admin | Filed under: Blog, Other

ZidoukenI found out this fantastic video on Youtube about problem solving using the “Zidane technique”, it’s really funny and not too shocking.
So, if you’re into a good laugh, check out the video by maecx. There’s also a t-shirt for sale with this summer hottest trend - Zidane.

PS: He’s a good player, no harm intended. :)

Flickr PhotoStream

    Gulbenkian GardenGulbenkian GardenBioshock DudeMilkbananaBig Totem Guy  at MegacampoRappel  at MegacampoPaintBall helmetsPaintBall helmets close-upPaintBall helmets

About

Hello. This is the home on the web of Pedro Sousa, a web developer who usually writes here about design, web, technology, lifestyle and other random ideas.

I love using Ruby on Rails and I'm pationate about creating applications and websites for people who use and live on the web. Enjoy your stay here.

Interesting