Skip to content

How to alias and create a new named scope out of existing ones

March 26, 2009

Named scopes in Rails are just awesome. They so much DRY and beautify your code! But did you ever had the trouble to create a new named_scope out of others? E.g. aliasing multiple ones to a new one. Luckily I now figured out how this works in a nice way.
The magic key is the method scope( :find )

This method called on a Scope class returns the Hash used for the ActiveRecord .find() call. First it’s a nice way to debug your scopes, second it’s perfect for our need to chain multiple scoped into one. Check this out:

class Fu < ActiveRecord::Base
named_scope :has_moo, :conditions => { :moo => true }
named_scope :has_foo, :conditions => { :foo => true }

named_scope :has_moo_and_foo, lambda { has_moo.has_foo.scope(:find) }

We chain the two scoped has_moo and has_foo together into a new one called has_moo_and_foo. As the return value can only be a Hash we use the above mentioned scope(:find) to transform it into one.

Now this works:


Sweet! Imagine how great this would be if we can return a scope object instead of a hash as well??

See my pastie here too.

LED Light Towers Installation

March 08, 2009

Hey, Check this out, a very nice LED tower installation:

see more great stuff at

[via Nercode]

How to deal with recurrency in Ruby & Rails

January 21, 2009

I did a short eval of projects dealing with re currency in Ruby and Ruby on Rails. Here a short list & rough of interesting projects dealing with repeating time (intervals):

Common used lilbrary:
A better runt(?):
Date extension, yahoo dev, rspec like:

Check this as well:

Love ActiveScaffold: Show always Searchbox

October 05, 2008

ActiveScaffold is a great plugin to build edit form easily. Nicely AJAX and nested forms support (well with limits ;-). One thing which bugged me all the time, was the extra click you had to do to show the searchbox. Well I solved it like this:

def index
active_scaffold_config.list.label += render_to_string( :action => :search, :layout => false )

I know, it’s kind of bad hack, as the label actually isn’t supposed to contain a form - but it works out quite well!

A short collection of Content Management Systems (CMS) for Ruby on Rails

July 01, 2008

Here is a short collection of current Content Management Systems (CMS) written in Ruby and mostly suited to use with Ruby on Rails. Check out Ananablau as well for a nice PDF slide.

Comatose (29. June 2007)
Comatose is a micro CMS designed for being embedded into existing Rails applications

Geego is for developers and designers that want to provide fully updatable websites for their clients.

Mephisto (27. July 2006)
Complete Blog System, Mephisto is a publishing system that makes it super easy to setup a blog or website.

Complete Blog System, Similar to Mephisto

Radiant CMS
Radiant is a no-fluff, open source content management system designed for small teams.
Looks cool but no direkt RoR integration?

Railfrog (3. July 2007)
Railfrog is a user-friendly, open-source website deployment and content management system built with Ruby on Rails.
dead project?!

Rubricks (31. July 2007)
Rubricks is a component based open source CMS powered by Ruby on Rails.

Seymore (04/02/2007)
Seymore is an open source content management system which integrates directly into pages.

SimpleCMS , (29. December 2007),
small simple, inline edit. Simple CMS is a very easy to use and pretty advanced CMS plugin.

CMSplugin provides your Rails application with a “CMS framework”. That means authentication, authorization, roles, permissions, categories, tags, etc… but from a very flexible scope.

open rcms (25.6.2007)

An in-place editor for your entire website. Roxanne is a simple Site-Management Tool to quickly manage your content. See first steps to get the idea behind Roxanne.

The first and most robust Ruby on Rails open source e-commerce project.

Goldberg (promising)

Beautify your views using "return"

June 06, 2008

A nice way to keep your views clean and not to spoil them with condition clauses, is to use the ‘return’ statement like you would do in a method:

Take this very simple exmaple:

unless @place


return if @place.nil?


There’s one pitfall, I forgot to mention: Every outout BEFORE the return statement will be discarded, so this part:

return if @place.nil?


Will result in an empty output as well. This is quite a pitty and I’m not sure if it’s a bug or feature. A may raise it soon..

SEO - Notes

January 23, 2008

This is just a list of SEO Notes I did years(!!!) ago. it’s mainly for me to remember stuff. Sorry this is in german.

guter strukturierter inhalt als text!! gute name/keywords in anker
guter individueller title, description, keywords,
interne links -> grüner, stockstreet, ompro
social bookmarks delicous, digger, mister-wong,
rss feeds -> feedburner
alt und title bei images,
h1, h2 tags
mehr css, weniger tables
check google sitemaps, analytics
linktausch! linkeinkauf!
keine (Wenige) params in URL
URL verlinken mit / am ende
keine frames! schon gar nicht iframes!!
eintragen in profiles flickr,
nutzen mit myspace, wikipedia, ebay, studvz, openbc, foren, protale, amazon??, blogs!!
achtung vor duplicate content!
301/302 weiterleiterungen, keine multidomains
google adsense????
achtung vor code injection -> Suchanfragen!!!!
sessionid killing
gute Kataloge nutzen: dmoz, bellnet,,
finde den HUB
credit, depotrechner, howto, tutorials fancy mit ajax gut verlinken
yahoo searchbuilder, ?? ??

Top Words:
Poker, Datenrettung, Kredit, Privatekrankenversicherung

My first AppleScript: Copy Address Book entries

May 10, 2007

Tatataa! I just wrote my frist AppleScript. For displaying the buddypicture of my Address Book contacts in Adium, I had to copy the ICQ entry to a new Jabber enrty with appending “”. The code follows:

tell application "Address Book"
set thePeople to every person whose ICQ handles is not {} and Jabber handles is {}
repeat with eachPerson in thePeople
set icqnr to value of ICQ handles of eachPerson
set jabberid to (item 1 of icqnr) & ""
make new Jabber handle at end of Jabber handles of eachPerson with properties {label:"Home", value:jabberid}
end repeat
save addressbook
end tell

It worked out fine. Now I see you all in my buddylist ;-)