Prevent “whenever” creating separate cron job on each deployment

I am using whenever gem for handling cron job in a Ruby on Rails application. It’s fantastic because of it’s very easy DSL to create tasks and schedule it. It will do all the dirty works to update crontab and run your task periodically as per your definition.

However, I ran into one problem that upon each deploy, whenever was creating a separate item in crontab. So when I’ve tried to check cron jobs (crontab -e), I see there are so many tasks.

It was doing this because I didn’t have :application param set in my capistrano settings (deploy.rb). Whenever depends on this name to match the existing names and update it. So all you need is to set application to your deploy.rb file.

set :application, 'your-fancy-app'

That should solve the problem. However, you need to manually cleanup current cronjob as it won’t update the current mess.

No source for ruby-1.9.3-p484 provided with debugger-ruby_core_source gem

I was getting this error when the ruby version is updated to 1.9.3-p484. When you’re using RVM, the solution is quite simple. Install the gem with the following command:

gem install debugger-linecache -v '1.1.2' -- --with-ruby-include=\$rvm_path/src/ruby-1.9.3-p484

If you need to install different version of debugger-linecache change 1.1.2 with appropriate version. If the you’re using different ruby version, change ruby-1.9.3-p484 to appropriate value.

Sunspot – power up your app with solr before knowing it

The title is a bit skeptical. Isn’t it? But trust me, it’s true. You can implement solr power searching in your Ruby on Rails application without knowing Solr. Yes, you off course know about Solr. What you don’t know is how to make it work for you. Let’s check how can you power your application with Solr using Sunspot gem.

What is Sunspot?

Sunspot is a Ruby library for expressive, powerful interaction with the Solr search engine. Sunspot is built on top of the RSolr library, which provides a low-level interface for Solr interaction; Sunspot provides a simple, intuitive, expressive DSL backed by powerful features for indexing objects and searching for them.

Using the sunspots DSL, you can easily implement solr powered searching. Its drop-in support with Rails models let you power your site with a few lines of codes.


Add the following line in your Bundle file.

gem 'sunspot_rails'
gem 'sunspot_solr'

Then run ‘bundle install’.  Continue reading →

Amistad – Facebook like friendship management in Ruby on Rails

Today I’ve decided to write something about the Ruby Gems that I used. So I’ve started this series (Ruby Gems). This is the first post of the series. I will try to write regularly.

When I was working on my pet project MovieMates, I needed to implement a friend relationship. Initially, I was going to do it myself. However, later I thought I should, at least, google a bit to check if there is already some similar solutions. Then I found Amistad.

The current version of Amistad supports ActiveRecord 3.0.x, Mongoid 3.0.x and MongoMapper 0.12.0.


Add following line to your Gemfile

gem 'amistad'

Continue reading →