Centralized rich content distribution in the web era

A typical global retail organization will have many points of sale (POS), and will usually require enriched content to be presented to customers. This is especially true in industries such as luxury watches, where it is important to educate customers as to what makes products so special (and expensive). It seems to me that the web is especially well suited to this purpose, as we’ll see. Continue reading

Posted in Thoughts | Comments Off

Using a partial as an optional layout

Rails uses partials a lot, and you can even use partials as mini-layouts. What I wanted to do is render flashes either as a normal partial (i.e. passing a string of text to be displayed), or as a layout (passing a block of markup to be rendered). Continue reading

Posted in Rails | Comments Off

Rake task with an external script using ActiveRecord

Using Rake to call an external script is quite straightforward: you can simply load it, or call “system”, or “exec”. By the same token, using ActiveRecord classes in a Rake task is easy: you just need to state your task depends on the environment (with “=> :environment”, as shown here).

Where it gets interesting is having an external script that can be used as a standalone, or called from within a Rake task. In my case, I wanted a script to load data from a file that would use ActiveRecord if possible (since it’s much faster), and fallback to Mechanize (to upload the data via the web forms). Continue reading

Posted in Rails | Comments Off

Icon links with data-uris (no CSS sprites !)

One step in getting to a snappy website experience is reducing HTTP requests. One technique contributing to this reduction is using CSS sprites for icon links. Today, however, I’ll show you how you can achieve the same objective using data-uris. The main advantage is that you’ll be able to work with your icons as single images, instead of having to organize them into a single image and keeping track of image offsets. Continue reading

Posted in Rails | Comments Off

Rails 3 in Action

Several months ago, I took a look at Rails 3 in Action by Ryan Bigg and Yehuda Katz. The publisher has since provided me with a copy of the first edition, and I’m pleased to say that while the eBook preview (which was missing some content) was good, the finished book is better yet. Continue reading

Posted in Rails | Comments Off

Automating web site interactions with Selenium

Dannon currently has a “promotion” called Cups of Hope where you can enter codes into their web page to donate money to breast cancer research. Entering data repeatedly gets old real fast, so I figured this would be a great example of using Selenium: it’s a practical example, yet simple enough to understand easily. Continue reading

Posted in Automation, Ruby | Comments Off

Selecting an option from dropdown form fields with Mechanize

Mechanize works great for uploading data through forms: it has great support for manipulating text fields, check boxes, and so on. Selecting the appropriate option from a dropdown is slightly more roundabout. Continue reading

Posted in Automation, Mechanize, Ruby | Comments Off

Uploading data using Mechanize

In this post, I’ll briefly describe a Mechanize script I wrote to update data in a web application. We’ll see how to navigate using Mechanize, and finding HTML elements with XPath.

The goal was simple: open a CSV file containing product references for catalog items and prices, and upload them into a Rails web app (by going to the edit page, entering the prices in the proper form fields, and submitting the form). Continue reading

Posted in Automation, Mechanize, Ruby | Comments Off

Posting forms with AJAX on checkbox toggle

In a recent Rails 3.1 project, I wanted to have some values updated via AJAX when a checkbox value is checked or unchecked. As I was unable to find anything on the subject online, I figured I would document it here. Continue reading

Posted in AJAX, CoffeeScript, jQuery, Rails | Comments Off

First encounter with the Rails asset pipeline and Coffeescript

I was working on a Rails 3.1 project, and wanted to have some javascript image preview functionality (much like this) in several places within the project. Since this project used the new Rails 3.1, I decided I’d do my best to throw together the image preview functionality in Coffeescript and use the asset pipeline. Continue reading

Posted in CoffeeScript, jQuery, Rails | 2 Comments