now with double the colour and flavor!

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.

Flickr PhotoStream

    Moo CardsMoo Cards Close-upPedro lacks political experienceMoo Cards for this winter :)old clockclose-up grassMacbook pro close-up on switchMacbook pro close-up keyboardMacbook pro close-up keyboardMacbook pro close-up keyboard

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 passionate about creating applications and websites for people who use and live on the web. Enjoy your stay here.

delicious

Don't Miss

SHiFT - Social and Human Ideas For Technology

Categories


Old and Wrinkled


Blogroll


Projects