ruby on rails
Ruby on Rails, Varnish and user dependent content
Ruby on Rails performance is a topic that has been widely discussed. Whichever the conclusion you want to make about all the resources out there, the chances you’ll be having to use a cache server in front of your application servers are pretty high. Varnish is a nice option when having to deal with this [...]
Give your Ruby console a dash of colour
When you’re developing an application in Rails (or Ruby), you spend lots of time in the IRB, the Interactive Ruby Shell. Usually just to test some Ruby code, start an application console or debug something going on inside the project. Yesterday, looking at a coworker screen, I saw he had his console with lots of [...]
Fix Java GUI applications in xmonad
If you ever try to run a GUI Java application when using xmonad as the Window Manager, you’ll probably end up with a nice flat grey window where your buttons, toolbars and other desktop GUI goodies should be. I ran into that problem the other day when trying to evaluate the RubyMine Ruby on Rails [...]
Ruby on Rails Many To Many associations with multiple databases
Sometimes you need to use multiple databases in your Rails projects. Usually when some data must be shared between different applications. When this happens you usually have some models in a shared database, and some other models in the specific application database. This can be easily done using the establish_connection method in the shared models [...]
Creating your own Job Managers in Ubiquo
Ubiquo is a Ruby on Rails, MIT Licensed Open Source CMS we develop and use at gnuine for a variety of projects. One of the features of Ubiquo is the ability to run jobs separately from the http requests to the site. Today I’m going to show you how to customize the Ubiquo Jobs plugin [...]
Iterate over a collection in groups, and other things
One thing I find fascinating about Ruby is the fact that most common tasks are already programmed for you in its library. The Enumerable module is a clear example of that, providing you with lots of functionality to manipulate collections of objects. One of those useful methods I discovered the other day was each_slice. This [...]
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 [...]