Articles

How to write a clean Ruby DSL - Part I: Why?

DSLs (domain specific languages) are a great way to make your app obvious – both obvious to understand, and obvious to maintain.

This series of posts will look at the power of DSLs, look at a plugin called Machinist, and then implement a simple example in Ruby.

The ever-wordy Wikipedia defines a DSL as:

Hello World Linux4Rails.com

The reason why we have decided to create this site is the idea of sharing our experiences and our experiments.

Googling on the net it’s enough easy to find tutorials, guides, how-to and solutions, so we are going to collect various stuff related to integration between the Linux OS and Ruby on Rails .

Rails 2.3 unitialized constant ActionController::Caching::Sweeper

The release candidate of rails 2.3.0 has a problem w/ autoloading the sweeper stuff. The problem is that it doesn’t.

The fix is here, but it isn’t included when you install from gems.rubyonrails.org. Instead, just freeze to edge (rake rails:freeze:edge) or patch it yourself.

HTH

Another look at integrating Scribd with your Rails application

Almost a year ago I wrote about integrating Scribd into your Rails application, and since then that feature has been working well in my applicant tracking system. Today, though, I got a request for information on how I display the documents that I send to Scribd, so I thought I’d share that, too.

Authlogic::Session::NotActivated (You must activate the Authlogic::Session::Base.controller with a controller object before creating objects)

To fix this, put:

1
before_filter :activate_authlogic

at the top of whatever controller is causing the issue

What's New in Edge Rails: Batched Find


This feature is scheduled for: Rails v2.3

ActiveRecord got a little batch-help today with the addition of ActiveRecord::Base#find_each and ActiveRecord::Base#find_in_batches. The former lets you iterate over all the records in cursor-like fashion (only retrieving a set number of records at a time to avoid cramming too much into memory):

Uploading files for enki using capistrano

Because the Enki blogging engine currently doesn’t have a method for uploading files for use in your posts I needed to come up with a quick and easy solution. This solution will also work for any website which doesn’t have an upload facility built in. The technique used is easily replicated.

Quicker Options For Irb Methods

Although irb does come with decent auto completion, I often prefer aliasing methods. To some degree I’ve come up with a decent solution to managing method aliases but what do you do when you want to alias a method’s options?

While working on a console-based rails app, I got tired of passing the same options hashes to an irb method:

Original Author Name: 
Gabriel Horner

finding who committed what

Sometimes you may find it necessary to figure out just who committed that bug, or perhaps compliment a coworker on how efficiently an algorithm was implemented. Or maybe not, you just want to know who broke the build. Luckily, the git blame command can help with figuring out exactly who’s responsible for which line and what commit it came from.

The basic usage is simply git blame . The console output usually looks like so (check out the full image!):

Video thumbnails with FFmpeg and Paperclip

We’ve spent the last few weeks working on a new Rails app for a film and photography site and, as you might expect from my recent

GitHub Rebase #28 | Rails Fire

GitHub Rebase #28

Send to friend

Now that news from the move has slightly settled down, it’s Rebase time! As always, if you’ve got awesome projects you’d like featured, feel free to send me a message.

Featured Project

yaws is not just another web server. It’s Erlang powered, so you get massive concurrent capabilities right out of the box. It’s got some basic support for dynamic content and plenty of other commonly needed pieces of web functionality that you can see examples of on its home page. There’s also a few web frameworks that use yaws, including ErlyWeb, Erlang Web, and Nitrogen. Not convinced yet? Check out some recent blogs that benchmark yaws against Tornado, nginx, and even Apache. If you’re writing a web app that needs the power and speed of Erlang, be sure to look at yaws and its related frameworks first.

Notably New Projects

testswarm is John Resig of jQuery fame’s latest adventure in advancing the web. I first saw this demoed at Developer Day Boston and was completely blown away. It’s distributed testing for JavaScript, brought to the max. The server basically gives each client a test suite, and they report the status of the tests back for the given browser. You can then watch results flying back to the server in real time. This is a new kind of approach for dealing with browser testing on a grand scale, and it’s definitely worth a watch to see where it goes.

webstats is a Ruby-based web interface to monitoring your Linux web server’s health. Install the gem, run webstats, and you’re done. Currently, you can check out CPU usage, load average, memory usage, disk usage, and disk activity. This is a cheap way to implement monitoring if you’re concerned about it, and it even comes baked in with an email and Growl notifier if something goes haywire.

Visage is another great option in the Ruby world of server stats apps. Unlike the previous entry, this seems to be more of a long term look at server history, and even provides some neat Raphaël graphs of the collectd stats on your system. Check out this blog post for a litttle hint of what it offers, and give it a spin!

ClojureX is an easy way to install the Clojure programming language for OSX. Since it uses submodules that links to the languages’ repo here on GitHub, you can stay up to date with the latest features coming out if you want. It also comes with some editor scripts for both TextMate and emacs. There’s plenty of more info on this blog post.

oh-my-zsh is a collection of great helpers and scripts for your new shell, zsh. Out of the box, it’s now got auto completion for rake and capistrano, git branch names, theme support, and more. It’s also got an auto-updater too if you’re the type that doesn’t like to be bothered by such primitive tasks. If you’re still on bash or haven’t looked into other shells than your default yet, definitely give this a look.

Images: