Ruby5

Daniel Willemse do 29 jul 10

This week, when looking for an answer to one of my ruby issues, I stumbled across
an awesome website called ruby5.envylabs.com

Where you can listen to, and get updated on the latest ruby news in a couple of minutes.
You can subscribe to it via iTunes, and it also has an RSS-feed.

Pretty easy to keep updated now, as you can just listen to it while doing your daily ruby business.

Check it out!

Gepost in hor |  0 reacties

Suppress Rails logging

Dax Huiberts wo 28 jul 10

When Rails applications get rather complex the amount of log statements can get rather big in development mode. It is not uncommon to get hundreds of lines of SQL log statements.

This creates a problem when you try to insert your own log statements. With all the noise it gets pretty difficult to filter out your own log statements. One way is to prefix your statements with “>>>>>>>>>>” or “==” (or many more of those). If that doesn’t even help there is alway the ‘tail -f log/development.log | grep =’. This is not a very workable sollution either. In this case you also miss your request information. Like how long the request takes or what the request parameters are.

I’ve been using the following code snippet for a week now and it really meets my need:

# config/initializers/suppress_rails_logging.rb

# suppress active record sql logging
class ActiveRecord::ConnectionAdapters::AbstractAdapter
  def log_info(*args); end
end

# suppress 'rendered partial ...' logging
module ActionView::RenderablePartial
  def render(view, local_assigns = {})
    super
  end
end

This snippet of code suppresses the ActiveRecord SQL logging statements and the ActionView ‘rendered partial …’ logging statements. It makes my logs useable again and I still don’t lose my request information logging statements.

Try it out and see for yourself wether this works for you. Please leave a comment for any feedback you have.

Gepost in hor |  1 reactie

Rails gem: Localized pluralization with i18n

Paul Engel di 27 jul 10

As you are working on an internalization Rails application, you are maybe using Globalize2 along with I18n to translate models (e.g. categories). The end-user is probably able to manage the translations in different locales such as Dutch, German, French, Spanish and so forth.

>> I18n.locale
=> :en
>> (c = Category.first).name
=> "birthday"
>> I18n.locale = :nl
=> :nl
>> c.name
=> "verjaardag"
>> I18n.locale = :fr
=> :fr
>> c.name
=> "anniversaire"

Sometimes you want to display the translation in pluralized form. For instance:

>> I18n.locale
=> :en
>> "Found " + c.name.pluralize
=> "Found birthdays"

A solution to accomplish this is to translate both singular and plural form:

>> I18n.locale
=> :nl
>> I18n.t("found").capitalize + " " + c.name_pluralized
=> "Gevonden verjaardagen"

There are some cons though:

  • you have to translate in singular AND plural form
  • you have to use two columns (name and name_pluralized)

That’s some sort of redundancy as we want to keep things DRY: only translate in singular form and pluralize the translation. Fortunately, there is a Rails gem that does just that:

Rich-pluralization is a E9s module which pluralizes words with inflection rules of the current locale. You can compare it with the ActiveSupport::Inflector, except that the inflections do not influence the Rails pluralization (which is used for methods as tableize and classify).

Looking at our previous example, this is what the implementation can look like:

>> I18n.locale
=> :nl
>> I18n.t("found").capitalize + " " + c.name.pl
=> "Gevonden verjaardagen"

And of course, you can pluralize static strings:

>> I18n.locale
=> :nl
>> "Fiets".pl
=> "Fietsen"
>> "MUSEUM".pl
=> "MUSEA"

Please note: the letter casing stays preserved(!)

All in all, using Rich-pluralization provides you to only translate in singular form and call .pl for the pluralized translation. Now isn’t that a DRY implementation?

At the moment, Rich-pluralization is shipped with Dutch inflections. It covers 86% of the 54977 words provided by INL. This will increase as the developers are working hard on improving the inflections. Also, you can also add inflections for other locales.

Please visit the Github project page if you are interested for more information.

Gepost in hor |  0 reacties

CSS3 Pie: Making your life as a webdesigner a little bit easier

Johan Vermeulen vr 23 jul 10

We all know how it’s like to create beautiful websites, slice it and see it work in all the major browser, except for Internet Explorer.

Enter CSS3 Pie: CSS decorations for IE. Jason Johnston of 327creative.com wrote a CSS library which can be used in Internet Explorer with the IE behaviors capability. This library partially adds CSS3 support to IE6/7/8.

Example:

Normally: plays nicely in FF/Safari/Chrome

#myElement {
  background: #EEE;
  padding: 2em;
  -moz-border-radius: 1em;
  -webkit-border-radius: 1em;
  border-radius: 1em;
}

For IE: Rounded borders \o/

#myElement {
  ...
  behavior: url(PIE.htc);
}

PIE currently has full or partial support for the following CSS3 features:

  • border-radius
  • box-shadow
  • border-image
  • multiple background images
  • linear-gradient as background image

Gepost in hor |  0 reacties

jQuery Hashchange

Stephan Kaag do 22 jul 10

Nowadays web apps do heavily depend on Ajax requests (think GMail).

As we all know: by using Ajax request we lose the possibility to bookmark specific pages and the possibility to use the back and forward buttons in our browsers because the url doesn’t change.

Ban Alman wrote javascript solution for this problem. Enter jquery-hashchange. This jQuery plugin enables very basic bookmarkable #hash history via a cross-browser HTML5 window.onhashchange event.

Version 1.3 was recently released. Check it out at github.

Gepost in hor |  0 reacties

RubyAndRails Conference 2010

Chiel Wester wo 21 jul 10

Yesterday the ticket sale for this year’s RubyAndRails Conference (formerly known as RubyEnRails) has started.

A new name for the conference, but also a new location. Last year the conference was held at the University of Amsterdam but this year’s conference will take place at Pakhuis de Zwijger, behind central station in Amsterdam. The conference will be a two day conference on 21 & 22 October 2010 including a Rails Rumble on the second conference day.

The first speaker on the conference has already confirmed, more will follow shortly. You can buy your ticket at the conference website on http://rubyandrails.eu. Tickets are for sale for € 149,00

Gepost in hor |  1 reactie

UKI Simple UI Kit for complex web apps

Roy van der Meij zo 18 jul 10

I just found out about UKI, a javascript framework.

Basically: you stop writing html code,
and start writing interfaces.

Now I’m not sure if I’m going to use this in production.
But it has been fun playing around with it.

Check it out and tell me what you think about it.

Gepost in hor |  0 reacties

Upgrading to rails 3.0

Daniel Willemse vr 16 jul 10

Seeing as upgrading your <3.0 rails app isn’t just changing the rails version in your env.rb I started looking for an easier way.
Scouring through the internet, I stumbled across this little gem + guide: rails-upgrade-automating-a-portion-of-the-rails-3

by Jeremy McAnally. I haven’t found time to play with it much, but I’ll definitely look into it more this weekend.

He also wrote a book railsupgradehandbook that gives you the basic tips / tricks to upgrade your app to a rails 3.0 app.

Gepost in hor |  0 reacties

Random Scraps

Wilco van Duinkerken do 15 jul 10

I didn’t check my RSS reader for a while, which resulted in a long list of unread posts. This is a summary collection of interesting tidbits.

bullet 2.0.0.beta.3 gem released

At @holderhq Bullet alongside New Relic saved us loads of time speeding up some database intensive apps. Especially when ActiveRecord magic and ActiveRecord extensions make your development log look like a wizards spell book describing how to fetch green goblins with red hats from middle earth.

Ruby Medicant University Game Mechanics

Gregory Brown’s Ruby Mendicant University idea is taking off. I think the idea is great and I’m closely following the progess.

Javascript Console with TextMate

I didn’t have the time to check it out yet. But it looks like this’ll certainly help javascript development.

Corporate Dictionary Part 7

Plainly funny.

Gepost in hor |  0 reacties

Bundler 1.0 without system gems

Wijnand Wiersma do 15 jul 10

The last time I talked about bundler I showed how to use the 0.9 series and everything will be in it’s own bundler bubble.
However, starting from bundler 1.0 systems gems will be prefered with sudo installs and this might be not what you want.

Some perfectly valid reasons might be:

  • You are deploying to webservers as an unprivileged user and don’t want to sudo
  • You don’t want the existing apps to break because incompatible gems are being installed

I was looking at the bundler source code for a solution and found out it was actually quite easy to solve.
Just add a path after “bundle install” !

So when installing an application on a production server you can let capistrano (or whatever you use for deployments)
run the following command: bundle install ~/.bundle

Inside the application a config file will be created and respected.
This configuration file consists of the following content:

--- 
BUNDLE_DISABLE_SHARED_GEMS: "1"
BUNDLE_PATH: /Users/wijnandwiersma/.bundle

As long as this configuration exists the system gems will not be touched.

Until recently I wasn’t a big fan of bundler but because of this presentation I fully understand all decisions that made bundler the way it is. I think you should watch it too. I think I will convert some rails 2.3 apps in the near future.

Gepost in hor |  0 reacties

Welkom op Holland On Rails

Het startpunt voor Ruby On Rails in Nederland. Vind de laatste technieken, meningen en nieuwtjes.

Recente Jobs

Gezocht: Ruby On Rails ontwikkelaar (junior of senior)

Eet, drink en droom jij over Ruby On Rails? Wil jij het liefste dag en nacht bezig zijn met jehobby; super coole webapplicaties ontwikkelen in Ruby On Rails?

Dan willen wij jou graag een podium bieden om je Ruby skills te vertonen aan onze nationale en internationale klanten!

@ Internetbureau Holder, Obdam

Bekijk alle jobs »»

Gereedschapskist

Onmisbare tools voor
iedere developer!
Ruby On Rails
Framework voor de web 2.0 developer. Eindelijk vooruitgang!
TextMate
Editor for true pro's
Typ, tab, top :-)
Nee, niet voor Win.
Made On A Mac
En nou is het over met die saaie grijze Windows bak van je!

Auteurs op deze site

Chris Obdam

'Less is more' evangelist, past dit ook dagelijks toe op zijn tandenborstel.

Chiel Wester

Snelheidswonder op Ruby wielen. Leuk om mee te pair-programmen ;-) Recommend Me
Src-120-attending

Stephan Kaag

Het eerste Rails coreteam- member uit Nederland? Rails evangelist van het eerste uur.

Paul Engel

Én Rails programmeren én interfaces designen? Je zou hem superman kunnen noemen..

Dax Huiberts

Official Zip-Programmer, skinny code is helemaal zijn ding. Haalt meer code weg dan dat er bij komt.

Freek Monteban

Het nieuwste telg uit het Holland on Rails nest! Hij doet niets anders meer!

Johan Vermeulen

De stylesheet-koning uit de kop van Noord-Holland!