//
archives

RailsBlogger

I'm a Software Developer with over 10 years of experience, Java and Ruby on Rails.
RailsBlogger has written 19 posts for Life Is Rails

A gem to create objects from external APIs

I published a gem to load into objects XML and JSON files provided over external APIs (urls). The gem is called api_object and available to be installed over “gem install api_object”. The gem is very easy to use. subclass your object to be loaded from ActiveApi::ApiObject class Station < ActiveApi::ApiObject end Specify the url to load the … Continue reading

Initialize Objects from a hierarchy of hashes (JSON format) in Ruby

There are some nice little functions to initialize Objects in Ruby from a hash. A good example could be found here. But sometimes, when we read an external API (XML or JSON) and parse the result, we get data which is a set of nested hashes and arrays. Then we want to initialize an object … Continue reading

Starting with Node.js – short introduction with resources

What is Node.js? It’s a Javascript library run on the V8 engine, the same one used in Google Chrome; and it’s used to create a server on a fly to run web apps. Advantages of it:– it’s slim and fast– it’s event driven 1. First question I asked was where Node.js is useful. Since Javascript … Continue reading

Fancybox gallery for an element with a tooltip: why is the first title not showing?

Please, refer to this article as a reference how to create fancy tooltips for elements and to the Fancybox site to see how to configure it to display images and galleries. The problem with the mentioned approach to create tooltips is that the “title” attribute gets reassigned and blanked out when we mouse over the … Continue reading

Using Cloud Zoom with a slide show: why the lens doesn’t work properly

I was trying to use the slideshow plugin from JQuery Tools with the Cloud Zoom plugin. In addition to having a slide show, I wanted to zoom in pictures in the slide show with Cloud Zoom. Please, refer to the links provided how to create a slideshow and configure Cloud Zoom for images. But the … Continue reading

Tutorial: Using Cucumber testing with MongoDB

This example is based on the following tutorial http://www.mongodb.org/display/DOCS/MongoDB+Data+Modeling+and+Rails. I recommend reading it to get familiar with how MongoDB is integrated with a Rails application. I rewrote the project using the TDD approach with Cucumber and the source code can be found on github 1. First of all, create a mock application with suspenders. gem … Continue reading

Cucumber and Factory Girl testing when having Single Table Inheritance

To get familiar with Single Table Inheritance, please, refer to this article Let’s assume, we have a web site requiring authentication and we have a User class that allows every user to log in, created with the gems Clearance and Suspenders such as described here, with a user name field added. Now, let’s have 2 … Continue reading

Factory Girl associations with MongoMapper

If you have an association (an Article belonging to a User) and you write something like that in Cucumber: Given the following article exists: | title | user | | My article | email: writer1@example.com | then the Factory Girl steps will handle this association for you, creating both an Article and a User for … Continue reading

Association testing in rspec with MongoMapper

As far as I know, MongoMapper is currently not able to handle association tests for rspec/shoulda, such as most common belongs_to, has_many, has_one. I think they are working on it, but it’s not there yet. I wrote a hack to work with MongoMapper, so far it’s able to handle my simple belongs_to association, and my … Continue reading

How to install Root and Intermediate SSL certificates for nginx

If you installed a reliable SSL certificate for your site, and your pages look fine in IE and Chrome, you still may see a message in Firefox that your site is untrusted instead of your page. In this case, check if you installed the root and intermediate certificates, not just the site certificate. Those certificate … Continue reading