A Month in Rails

Posted by Gregg Pollack September 02, 2009 @ 01:56 PM

Lots of great content coming out of the community in the past month. Below you’ll find some of the most useful tutorials and libraries I’ve found over the past few weeks. These stories came directly from the Ruby5 podcast, which covers news from the Ruby and Rails community twice weekly.

Improving your Rails code

James Golick released a gem called Observational recently which provides you with a better way of using observers in Rails. Instead of creating one file per observer, this gem allows you to define multiple observed objects and specific methods to call for each object’s events.

If you want to develop a Rails app that takes advantage of Subdomains Taylor Luk has the recipe. He recommends using subdomain-fu, shows how to use a Proxy PAC file in development, and introduces a piece of Rack middleware he wrote which allows you to use full custom domains in your application.

If you like to TATFT like the rest of us, I have two libraries to tell you about. The first is a gem by the guys over at Devver called Construct which makes it easy to test code which interacts with your filesystem. The second is Blue Ridge by Larry Karnowski and Chris Redinger which makes it easy to write tests for your javascript. Blue Ridge has been out for a while, but this week Noel Rappin wrote a great introductory article to get you started.

Just yesterday Fabio Akita put together a screencast showing how the “Weblog in 15 minutes” code could be simplified using Inherited Resources, a gem by José Valim which helps reduce controller code duplication. The gem uses the same sort of technique you may have seen before with make_resourceful or resource_controller, but has improved syntactic sugar.

Libraries you should know about

Patrick McKenzie released A/Bingo, a gem/plugin for your Rails application that makes A/B Testing easy. It uses a fairly intuitive and simple interface for defining your tests and provides information on which sample performed best and by what margins.

Steve Richert released a gem called vestal_versions which allows you to keep a history of all of your ActiveRecord model changes in your database. It takes advantage of several newer features in Rails 2.2+ including recognizing dirty objects.

Railscast #176 by Ryan Bates covered Searchlogic by Ben Johnson, which makes it really easy to create advanced search forms in Rails.

David Bock released new gem called Crondonkulous which allows you to write crontab recipes in Ruby from within your Rails application. These recipes get automatically published to your server’s crontab when you deploy.

Security

James Harton released Lockbox and acts_as_lockbox, which provide a simple interface for securing sensitive data by managing RSA public key cryptography for your application. This allows you to define which attributes are sensitive and provides an application-wide locking and unlocking ability.

Hongli Lai wrote up a great article on keeping your user’s passwords secure. He writes about how to store passwords, hashing algorithms, salting, and more. Specifically, he recommends using Blowfish File Encryption, or “bcrypt,” because it’s a slower-running algorithm which will make it more difficult to crack.

In your Database

Mauricio Linhares released a plugin for Rails which allows you to do master / slave replication. Unlike masochism, master_slave_adapter works in conjunction with the Rails database connection pool and is implemented as a new database adapter. So, no monkey patching necessary.

Matt Jankowski provided a great article on properly indexing your database for your Rails application. He covers indexing validation and STI columns, state columns for state machines, association columns, and more.

The developers of xing created a plugin called FlagShihTzu. It’s not a dog.. or even a multiplayer game for your Tamagotchi. FlagShihTzu stores any number of ActiveRecord boolean model attributes as a single database field, using each bit as unique keys. But, the interesting part is that the interface remains exactly the same to the rest of your application.


Thanks for reading and if you have any news or libraries you’d like to get the word out about, feel free to drop me a line by submitting news over at Ruby5.

Image Credit: Blue Sky on Rails by ecstaticist, Analog Solutions 606 Mod by Formication, RailsConf Europe 2006 by Paul Watson, Rainbow by One Good Bumblebee. Orange County Security by henning

Posted in Activism | 6 comments

Comments

  1. Neeraj on 02 Sep 14:53:

    Blue-Ridge looks good. I wrote on getting started last week.

    http://www.neeraj.name/blog/articles/873

  2. Amit on 02 Sep 18:23:

    Searchlogic screencast by Ryan Bates was quite informative along with for vestal_versions.

  3. Alex on 02 Sep 21:15:

    I don’t like to test javascript this way, definitely we should replace such techniques by lyndon, johnson + nokogiri.

  4. Eloy Duran on 04 Sep 06:36:

    At Fingertips we use HeadlessSquirel to run our JavaScipt unit tests: http://github.com/Fingertips/headless-squirrel http://superalloy.nl/2009/04/14/headless-squirrel.html

    Plus Kicker to automatically run them http://github.com/alloy/kicker. Which reminds me that I should merge our Kicker recipes asap. But the gist of it for the JS tests, include the following in a .kick file in your source root and run $ kicker> # Match javascript changes and run with HeadlessSquirrel Kicker.process_callback = lambda do |kicker, files| test_files = [] files.delete_if do |file| case Path.relative(file) when %r{^test/javascripts/(\w+)_test\.(js|html)$} when %r{^public/javascripts/(\w+)\.js$} else next end test_files << "test/javascripts/#{$1}_test.html" end kicker.execute_command "jstest #{test_files.join(' ')}" unless test_files.empty? end

  5. Eloy Duran on 04 Sep 06:38:

    Ugh, formatting fail.

    # Match javascript changes and run with HeadlessSquirrel
    Kicker.process_callback = lambda do |kicker, files|
      test_files = []
    
      files.delete_if do |file|
        case Path.relative(file)
        when %r{^test/javascripts/(\w+)_test\.(js|html)$}
        when %r{^public/javascripts/(\w+)\.js$}
        else
          next
        end
        test_files << "test/javascripts/#{$1}_test.html" 
      end
    
      kicker.execute_command "jstest #{test_files.join(' ')}" unless test_files.empty?
    end
    
  6. UGG Classic Cardy on 12 Sep 05:41:

    Only One word to characterize such a great post “WOW” that was a very interesting read