Think In Geek

In geek we trust

ruby on rails

Easily select random records in rails

If you ever wondered how to easily retrieve a random record in an ActiveRecord model, here’s en easy way to do that: use the sample method. sample is a class method from the Array class that retrieves one or more random items from an array instance. It conveniently returns nil or an array lesser than […]

, , ,

Fixtures and serialized attributes in Ruby on Rails

If you’ve ever used the serialize method in an ActiveRecord model, you may have faced the problem of writing a fixture for that particular serialized field. The serialize method is quite handy if you need to store a complex object (like a Hash or an Array) in a database field, without having to create additional […]

, , , ,

Create your own JSONP Proxy using Ruby on Rails

Today I was working on a web site that needs to retrieve some RSS feed over the internet. Since the web page has no server (HTML + javascript only) I couldn’t access the feed from the server side. Also, because of the Cross Domain limitation of Ajax requests, I couldn’t access the RSS in the […]

, , ,

Killing all rails logs with one Ctrl+C?

Well, this is my first post after holidays and it won’t be very long. Imagine you are developing a rails application. Usually you have: a terminal with the server to see what petitions are received. a terminal with a tail of development.log to see what happens with the database. a terminal with a tail of […]

, , ,

Subversioning a Rails App

The time when application versions where stored in different folders or in zip files has ended. Today we have great tools like Subversion or CVS. This tools must be known by everybody, but for those who aren’t known, they are applications that control versions of files. While developing a Ruby on Rails application it’s good […]

,

Next posts