to_s FTDRY

Wijnand Wiersma do 02 sep 10

Here is just a quick tip: define more to_s methods on your models to DRY up you views. It’s a very Ruby thing to do and if you keep this method fairly on top of your classes it won’t be very confusing for other developers.

For one project I have 3 models: include, exclude and split. When I want to display them I only want to show the only defined property they have: path

I display them regularly in views and it gets used in background processes where it is concatenated into a bigger string.

So instead of writing include.path everytime I went for this approach:

def to_s
  path
end

From now on I can do something like this in my views:

<li><%= include %></li>

And where it gets concatenated:

"#{first_include} something here #{second_include}"

or a array gets joined:
includes.join(" ")

Another nice example might be a person class where you display the persons name regularly in views. If you keep the parts of the name in multiple properties you are getting a bigger win:

def name
  [first_name, last_name_prefix, last_name].reject{|x|x.blank?}.join ' '
 end

So if you display an object as a string a lot defining a to_s method and just put in your plain object in your view will certainly a nice way to get more DRY.

Gepost in hor |  0 reacties

It's Rails 3 time!

Chiel Wester ma 30 aug 10

After years of development by the Rails Community the 3rd version of Rails is finally ready! The number of new features and improvements is enormous!

Are you ready to upgrade your application to this new version of Rails? Just use the Rails 3 upgrade handbook

Gepost in hor |  0 reacties

Rails 3.0: Release candidate 2

Stephan Kaag vr 27 aug 10

According to DHH the release candidate process is progressing as planned. This second candidate has very few changes over the first, which means that unless any blockers are discovered with this release, we’re targeting the final release of Rails 3.0 for this week(!!!).

Gepost in hor |  0 reacties

RVM goes 1.0

Jeroen Bulters do 26 aug 10

Exactly one year after the first installment of the Ruby Version/enVironment Manager (pick your flavour) we’re pleased to see the 1.0 release of this magnificent tool.

For those of you not familiar with RVM, it allows you to easily switch between different versions of Ruby and accompanying gems, even allowing you to run multiple versions simultaneously.

Easy (initial!) installation is done through:

bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

The ‘press release’ is available here, the website at BeginRescueEnd and the source at github.

Gepost in hor |  0 reacties

No more slow Date / DateTime

Daniel Willemse do 26 aug 10

Jeremy Evans recently brought out a new gem called home_run
What it does is, it replaces the Date and DateTime classes of the standard ruby library, with a C version of them. (works with both ruby 1.8 and 1.9)
Why should you get it?
Because the gem has proven to be up to 250 times faster than the standard library. This may vary depending on a few factors like ruby version and OS, but in every single case, its faster than the ruby implementation.

There are a couple of downsides to this gem, in that its not 100% compatible with the ruby library. Read up and decide for yourself if this is the gem for you.

Gepost in hor |  0 reacties

Ruby Koans

Dax Huiberts ma 23 aug 10

Ruby Koans is a new interesting project to help you learn Ruby using a test driven approach.

The Koans walk you along the path to enlightenment in order to learn Ruby. The goal is to learn the Ruby language, syntax, structure, and some common functions and libraries. We also teach you culture. Testing is not just something we pay lip service to, but something we live. It is essential in your quest to learn and do great things in the language.

Some more info about the structure of Ruby Koans:

The koans are broken out into areas by file, hashes are covered in about_hashes.rb, modules are introduced in about_modules.rb, etc. They are presented in order in the path_to_enlightenment.rb file.

Each koan builds up your knowledge of Ruby and builds upon itself. It will stop at the first place you need to correct.

Some koans simply need to have the correct answer substituted for an incorrect one. Some, however, require you to supply your own answer. If you see the method __ (a double underscore) listed, it is a hint to you to supply your own code in order to make it work correctly.

I’ve taken it for a short run and it’s very enlightening and entertaining. There’s no doubt you will learn some Ruby features or tricks you don’t know about yet.

Gepost in hor |  0 reacties

New speakers announced for RubyAndRails 2010

Chiel Wester vr 20 aug 10

We have announced some very interesting talks the last weeks for the RubyAndRails Europe Conference (21-22 October in Amsterdam):

More speakers will be announced soon!

Tickets for the conference are still available via the conference website (http://rubyandrails.eu)

There is also still room for some teams for the Ruby Rumble on the second day of the conference. You can read more about that on the website!

We hope to see everyone on 21 and 22 October in Amsterdam!

Gepost in hor |  0 reacties

August 19th: It's Why day!

Paul Engel do 19 aug 10

Today, it has been 1 year already that Ruby tycoon / legend Why the Lucky Stiff (_why) has erased his online existence.

Why has provided many beautiful libraries for Ruby community. His list of contributed content is impressive, just to name a few:

Most of them can be characterised as compact, abstract, beautiful and efficient. I doubt there will be someone else like Why.

We miss you, Why! Hoping you’ll return someday.

Gepost in hor |  0 reacties

Ruby 1.9.2 released

Johan Vermeulen do 19 aug 10

Yuki Sonoda (Yugui) just announced the release of Ruby 1.9.2

Ruby 1.9.2 has the following changes:

  • Many new methods
  • New socket API (IPv6 support)
  • New encodings
  • Random class that supports various random number generators
  • Time is reimplemented. There is no longer the year 2038 problem.
  • some regexp enhancements
  • $: no longer includes the current directory.
  • dl is reimplemented on top of libffi.
  • new psych library that wraps libyaml. You can use the library instead
    of syck.

Gepost in hor |  0 reacties

Reverse search in IRB

Roy van der Meij ma 16 aug 10

I just noticed this blog post: improve irb and fix it on mac osx
The first part had my most interest: Reverse searching in irb

And I have to say: WOHOOO :)

In terminal I use reverse searching with ctrl-R a lot.
In case you don’t know, with reverse searching you can easily search in your history of commands.
It’s definitely my choice of weapon in stead of bashing the up key.

Gepost in hor |  1 reactie

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!