How to decrease coupling in your controllers & views with decent_exposure for better maintainability

Posted on

If you're a Rails developer, you're familiar with with the standard way of sharing data from the controller layer to the view layer. By convention, Rails copies all instance variables defined in the execution of a controller action to the view context. This standard usage will result in strong coupling between your controllers and views, as they are sharing state via instance variables. To solve this problem, Stephen Caudill created the decent_exposure gem ...

Read More

Generating a Sitemap for your Rails sites

Posted on

A sitemap according to Wikipedia is "a list of pages of a web site accessible to crawlers or users." While they are completely optional, Google uses the sitemap on your site to learn about it's structure. This allows Google and other search engines to potentially increase crawling coverage. While you can build this yourself manually via XML Builder or handcrafting an XML file, I prefer using the sitemap_generator gem.

Read More

Generate Controller-Wide ETags [Rails 4 Countdown to 2013]

Posted on

One of the new features in Rails 4 is the ability to suffix controller-wide information to ETags. At the controller class level, you can set data by passing a block to the new `etag` macro style method. The etag method can be called multiple times, with each subsequent call suffixing the information to the response's ETag for easy client-side caching.

Read More

Using Sidekiq to send emails asynchronously

Posted on

Sidekiq A lot of Ruby developers are familiar with queues, such as DelayedJob and Resque. While these queues have been predominant the last couple of years, my tool of choice is Sidekiq, a Redis backed queue by Mike Perham. Sidekiq advertises that a single process can do the work of 20 Resque or DelayedJob processes. Another benefit of Sidekiq is the inclusion of extensions, which allows for testing and delayed mailers.

Read More