MinneBar 2008

Posted 3 days back at Rail Spikes

MinneBar Logo

MinneBar – one of the largest BarCamps in the world – is being held this Saturday at the University of Minnesota.

Several folks from the Rail Spikes/Slantwise/Tumblon orbit will be presenting.

  • Jon will be speaking about Consulting for fun and profit based on his experience with Slantwise as well as demoing Tumblon.
  • Norm will be sitting on the Design Coding Panel as well as leading a session on CSS frameworks
  • Dan Grigsby (Rail Spikes alum) will be sitting on the State of the State: Technology in Minnesota panel and giving a talk called Screw You LAMP. Plus Virtualization.

Me? I’ll be helping run the thing and maybe giving a demo.

There’s 360+ people signed up already. If you’re in the area, you should definitely come. It’s going to be awesome.

The Best of RubyFlow - April 24 to May 5, 2008

Posted 6 days back at Ruby Inside

RubyFlow - the community based companion site to Ruby Inside - has been on fire! I’m finding out about lots of new stuff on there that then gets included into Ruby Inside posts. It’s the place to be if you want the most up to date Ruby and Rails news, but don’t mind putting up with a bit of ‘noise’.

Every two weeks or so I’m going to summarize some of the best items from RubyFlow here on Ruby Inside, so that you can still keep up with the latest developments even if you don’t want to be soaked in the firehose of Ruby news over there.

For the period April 24 to May 5, 2008:

Net::SSH 2.0 Released: Jamis Buck announces the release of Net::SSH 2.0 and the availability of Net::SFTP 2.0, Net::SCP 1.0, Net::SSH::Gateway 1.0 and Net::SSH::Multi 1.0.

Webistrano 1.3: Webistrano 1.3 has been released; read the announcement. Webistrano is a Web UI for managing Capistrano deployments. It lets you manage projects and their stages like test, production, and staging with different settings. Those stages can then be deployed with Capistrano through Webistrano.

Automatic Migration Generator: Hobofields is an automatic migration generator for Rails / ActiveRecord users. Annotate your model with the fields required as you go, then Hobofields generates the required migrations.

Capistrano 2.3.0: Yehey! Capistrano 2.3.0 is released. It has many new tasty features!

Rails 2.1 Features: A summary of some of the nice new features coming in Rails 2.1. In short, many of the rough spots are being patched over!

Ruby and TextMate: An interesting introduction to TextMate’s Ruby bundle. A good place to start if you use TextMate but haven’t used any of the mnemonics and snippets the Ruby bundle provides (like me).

John Lam on Iron Ruby: A video update on Iron Ruby from John Lam recorded by David Laribee.

MetricFu: Jake Scruggs demonstrates how to use MetricFu to produce good looking metrics and reporting for your Rails application.

Merb Blogging Software: Announcing Feather, a Merb based blogging engine with a lightweight core framework, and a robust set of plugins, now open source and ready for contributions!

Parsing Quoted Strings: If you need to parse quoted strings in Ruby, a lesser-known module called Shellwords from the Ruby Standard Library is a handy utility.

Rails gets more mature

Posted 9 days back at Rail Spikes

Rails 2.1 is right around the corner. I’ve been following the new features in Edge Rails and eagerly looking forward to this release. Rails 2.1 includes a number of features that will make developers’ lives easier. Here’s a few of my favorites.

Necessary directories created if they don’t exist

Neither Mercurial nor Git track empty directories. This is a pain with Rails, because you have to create a file in the log directory to make sure it gets created when you check out code, otherwise Rails won’t start. This is no longer needed, because Rails will create necessary directories if they don’t exist.

Time zone support

Time zones are a huge pain in any application, in any language because they are just plain confusing. But ya gotta do it. In Rails, the solution used to be using the TzTime and TzInfoTimeZone plugins. Rails 2.1 adds support for tracking Time objects with their time zone. This is going to make everyones’ lives a lot easier. Check out Geoff Buesing’s in-depth tutorial.

Partial updates and “dirty” tracking

Two features that I knew and loved in our home-brew ORM from my former life as a Java developer have made it into Rails.

With dirty objects you can know if you need to persist an object, and which attributes have changed, and what an attribute’s previous value was. This will be great for user messages and validations!

In Rails 2.1, ActiveRecord can update only the attributes which have changed. This can (sometimes) put your objects into an inconsistent state, but partial updates improve performance, especially when you have big TEXT or BLOB attributes that haven’t changed. Use optimistic locking to prevent users from stomping on each others’ changes.

Timestamped migrations

With all this distributed SCM going on, the classic problem of messed up migrations gets way worse. I talked about solutions to this in my talk at acts_as_conference, one of which was timestamped migrations. Timestamped migrations allow interleaved migrations. As long as those migrations don’t conflict with each other, they can be applied in any order. This has been added to Rails. Nice!

Better gem dependency and unpacking

I am a big fan of the vendor everything approach to gems because I got burned way too many times by missing gems.

But it doesn’t always work (for example, gems which must be natively compiled are a problem), and you have to install one of the various vendor everything plugins—and everyone seems to use a different one. In Rails 2.1, gem unpacking is built in with rake gems:unpack GEM=gemname. (more info)

And for those gems that don’t work, you can list them as a dependency. Your app will fail to start if the gem is not installed. Fail early, fail often!

Text helpers usable outside the view

You can now use helpers without including them into your class. Hurray!

Rails gets more mature

Posted 9 days back at Rail Spikes

Rails 2.1 is right around the corner. I’ve been following the new features in Edge Rails and eagerly looking forward to this release. Rails 2.1 includes a number of features that will make developers’ lives easier. Here’s a few of my favorites.

Necessary directories created if they don’t exist

Neither Mercurial nor Git track empty directories. This is a pain with Rails, because you have to create a file in the log directory to make sure it gets created when you check out code, otherwise Rails won’t start. This is no longer needed, because Rails will create necessary directories if they don’t exist.

Time zone support

Time zones are a huge pain in any application, in any language because they are just plain confusing. But ya gotta do it. In Rails, the solution used to be using the TzTime and TzInfoTimeZone plugins. Rails 2.1 adds support for tracking Time objects with their time zone. This is going to make everyones’ lives a lot easier. Check out Geoff Buesing’s in-depth tutorial.

Partial updates and “dirty” tracking

Two features that I knew and loved in our home-brew ORM from my former life as a Java developer have made it into Rails.

With dirty objects you can know if you need to persist an object, and which attributes have changed, and what an attribute’s previous value was. This will be great for user messages and validations!

In Rails 2.1, ActiveRecord can update only the attributes which have changed. This can (sometimes) put your objects into an inconsistent state, but partial updates improve performance, especially when you have big TEXT or BLOB attributes that haven’t changed. Use optimistic locking to prevent users from stomping on each others’ changes.

Timestamped migrations

With all this distributed SCM going on, the classic problem of messed up migrations gets way worse. I talked about solutions to this in my talk at acts_as_conference, one of which was timestamped migrations. Timestamped migrations allow interleaved migrations. As long as those migrations don’t conflict with each other, they can be applied in any order. This has been added to Rails. Nice!

Better gem dependency and unpacking

I am a big fan of the vendor everything approach to gems because I got burned way too many times by missing gems.

But it doesn’t always work (for example, gems which must be natively compiled are a problem), and you have to install one of the various vendor everything plugins—and everyone seems to use a different one. In Rails 2.1, gem unpacking is built in with rake gems:unpack GEM=gemname. (more info)

And for those gems that don’t work, you can list them as a dependency. Your app will fail to start if the gem is not installed. Fail early, fail often!

Text helpers usable outside the view

You can now use helpers without including them into your class. Hurray!

RubyFringe keeps rolling

Posted 10 days back at Rail Spikes

RubyFringe is shaping up to be a pretty kick-ass event. Besides tons of great speakers (present company excluded), they are having all-inclusive parties every night, and no lame sponsors to dilute the signal to noise ratio. Keeping attendance capped at 150 also ensures awesomeness, because everyone will get a chance to meet everyone else.

It’s also the only conference out there that I know of that has activities for your non-technical girlfriend/boyfriend/wife/husband/whatever. That is such a great idea.

July 18-20 in Toronto, Ontario (aka Accordion City). Registration ends June 11. Get on it.

RubyFringe keeps rolling

Posted 10 days back at Rail Spikes

RubyFringe is shaping up to be a pretty kick-ass event. Besides tons of great speakers (present company excluded), they are having all-inclusive parties every night, and no lame sponsors to dilute the signal to noise ratio. Keeping attendance capped at 150 also ensures awesomeness, because everyone will get a chance to meet everyone else.

It’s also the only conference out there that I know of that has activities for your non-technical girlfriend/boyfriend/wife/husband/whatever. That is such a great idea.

July 18-20 in Toronto, Ontario (aka Accordion City). Registration ends June 11. Get on it.

Quick tip: store_location with subdomains

Posted 10 days back at Rail Spikes

Both restful_authentication and the older acts_as_authenticated have a handy method called store_location. This method stores a URL in a session variable for future reference. The obvious use case involves login. For example, if you’re browsing a product anonymously and want to write a review, you’ll need to sign in first. So if you click a link on that product page that requires you to be logged in, and this sends you through the login process, you’ll ideally want to be returned right back to where you were before you logged in. store_location enables this, along with the redirect_back_or_default(), also provided by Rick Olson’s authentication plugins.

You store a location like this:

1
2
3
4
5
6
7

  def private_action
    unless logged_in?
      store_location
      redirect_to login_path
    end
  end

After authenticating the user, you send them back to the stored location with this:

1
2
3
4
5
6

  def login
    if login_successful? # pseudocode, obviously
      redirect_back_or_default(home_path)
    end
  end

If a location is stored in session, redirect_back_or_default will send the user that location. Otherwise, it redirects to the default path.

This is pretty handy. But unfortunately, it doesn’t jump across domains, including subdomains. Tumblon lets parents set up blogs for their families, and these blogs are either identified by a subdomain (e.g. myfamily.tumblon.com) or by a top-level domain (coming soon). Tumblon also has privacy controls, so I can set a story to be viewable only by my family and friends. So if an anonymous user hits the URL of a private photo/story/video, they should be redirected to the login screen and then right back to the item they were trying to view. But out of the box, store_location can’t handle this.

Let’s look at the store_location method to see why. This method is in lib/authenticated_system.rb.

1
2
3
4

    def store_location
      session[:return_to] = request.request_uri
    end

store_location uses the request.request_uri method, which only provides the relative path (e.g. /photos/932783). So if you login at tumblon.com, store_location won’t return you to myfamily.tumblon.com/photos/932783 – it will send you to tumblon.com/photos/932783. Your app could have logic to redirect from this page to the subdomain, but an easier solution is just to create a new store_location method, like store_location_with_domain. Or you could always override the store_location method to always use request.url instead of request.request_uri if you don’t want a separate method.

1
2
3
4

    def store_location_with_domain
      session[:return_to] = request.url
    end

Put this method in application.rb, and you can now use redirect_back_or_default to hit an exact URL – complete with subdomain, top-level domain, and port.

Quick tip: store_location with subdomains

Posted 10 days back at Rail Spikes

Both restful_authentication and the older acts_as_authenticated have a handy method called store_location. This method stores a URL in a session variable for future reference. The obvious use case involves login. For example, if you’re browsing a product anonymously and want to write a review, you’ll need to sign in first. So if you click a link on that product page that requires you to be logged in, and this sends you through the login process, you’ll ideally want to be returned right back to where you were before you logged in. store_location enables this, along with the redirect_back_or_default(), also provided by Rick Olson’s authentication plugins.

You store a location like this:

1
2
3
4
5
6
7

  def private_action
    unless logged_in?
      store_location
      redirect_to login_path
    end
  end

After authenticating the user, you send them back to the stored location with this:

1
2
3
4
5
6

  def login
    if login_successful? # pseudocode, obviously
      redirect_back_or_default(home_path)
    end
  end

If a location is stored in session, redirect_back_or_default will send the user that location. Otherwise, it redirects to the default path.

This is pretty handy. But unfortunately, it doesn’t jump across domains, including subdomains. Tumblon lets parents set up blogs for their families, and these blogs are either identified by a subdomain (e.g. myfamily.tumblon.com) or by a top-level domain (coming soon). Tumblon also has privacy controls, so I can set a story to be viewable only by my family and friends. So if an anonymous user hits the URL of a private photo/story/video, they should be redirected to the login screen and then right back to the item they were trying to view. But out of the box, store_location can’t handle this.

Let’s look at the store_location method to see why. This method is in lib/authenticated_system.rb.

1
2
3
4

    def store_location
      session[:return_to] = request.request_uri
    end

store_location uses the request.request_uri method, which only provides the relative path (e.g. /photos/932783). So if you login at tumblon.com, store_location won’t return you to myfamily.tumblon.com/photos/932783 – it will send you to tumblon.com/photos/932783. Your app could have logic to redirect from this page to the subdomain, but an easier solution is just to create a new store_location method, like store_location_with_domain. Or you could always override the store_location method to always use request.url instead of request.request_uri if you don’t want a separate method.

1
2
3
4

    def store_location_with_domain
      session[:return_to] = request.url
    end

Put this method in application.rb, and you can now use redirect_back_or_default to hit an exact URL – complete with subdomain, top-level domain, and port.

Quick links

Posted 11 days back at Rail Spikes

MySQL’s Over-looked and Under-worked Slow Query Log.

Dynamite is a JRuby interface to Processing.

How to send multipart/alternative e-mail with inline attachments.

Prototip and Starbox are awesome.

Note to self: alias_method_chain doesn’t work with ActiveRecord attributes.

Rails Search Benchmarks comparing Ferret, Solr, and Ultrasphinx.

Extend String to use ActionView’s Text Helpers. I may have to add this to my standard bag of tricks. Wish it was in core. Fortunately, in Edge Rails, the helpers are now accessible by module. Nice!

ar_mailer: how to avoid memory related issues and Running ar_sendmail with monit.

Timeframe is a totally awesome looking Javascript date picker.

Datejs parses human dates in JavaScript. Very cool.

Promise and Peril for Alternative Ruby Impls. JRuby’s Charles Nutter takes a look at the state of the alternative Ruby implementations and the challenges they face. I hadn’t heard of MacRuby before—sounds like it will be a great way to write Mac OS X apps. MagLev (Ruby with Smalltalk VM technology) also sounds interesting (interview) but I imagine it will cost booku bucks.

Seed Fu is a new library for loading seed data.

Quick links

Posted 11 days back at Rail Spikes

MySQL’s Over-looked and Under-worked Slow Query Log.

Dynamite is a JRuby interface to Processing.

How to send multipart/alternative e-mail with inline attachments.

Prototip and Starbox are awesome.

Note to self: alias_method_chain doesn’t work with ActiveRecord attributes.

Rails Search Benchmarks comparing Ferret, Solr, and Ultrasphinx.

Extend String to use ActionView’s Text Helpers. I may have to add this to my standard bag of tricks. Wish it was in core. Fortunately, in Edge Rails, the helpers are now accessible by module. Nice!

ar_mailer: how to avoid memory related issues and Running ar_sendmail with monit.

Timeframe is a totally awesome looking Javascript date picker.

Datejs parses human dates in JavaScript. Very cool.

Promise and Peril for Alternative Ruby Impls. JRuby’s Charles Nutter takes a look at the state of the alternative Ruby implementations and the challenges they face. I hadn’t heard of MacRuby before—sounds like it will be a great way to write Mac OS X apps. MagLev (Ruby with Smalltalk VM technology) also sounds interesting (interview) but I imagine it will cost booku bucks.

Seed Fu is a new library for loading seed data.


1 2 3 ... 25