Redline Software Inc. - Winnipeg's Leader in Ruby on Rails Development

Conditional Cache Updates

I’ve recently fixed a bug in our conditional cache plugin that I introduced while making it compatible with Rails 1.2.4.

The bug has been fixed and the plugin also works with Rails 1.2.5.

The bug was causing the wrong cache paths to be created, so if you updated the plugin, update again ASAP.

Redzone Leagues New Website

The Redzone Leagues website got a fresh coat of varnish today. The goal of the new layout is to provide new and existing users with information that is not only easier to find, but also presented in a cleaner, more polished fashion.

Like always, if you have feedback we’d love to hear from you!

New In_place_editor Plugin

I have just released a new plugin that can be found at http://agilewebdevelopment.com/plugins/improved_in_place_editor

This plugin allows all options of the Ajax.InPlaceEditor control to be set. This will also work with the new rewrite of the control, which is currently in the scriptaculous trunk.

This plugin replaces the current rails version of in_place_editor and is drop-in compatible.

Quick summary (more details at the url above)…

Missing options such as onFailure can now be specified…

1
<%= in_place_editor 'field_id', :on_failure => "function(transport) {alert(\"Error: \" + transport.responseText.stripTags());}" %>

Some options require quoting to be valid in the JS, such as :highlight_color.1

1 :highlight_color is the option name for the rewritten version of the control, :highlightcolor is the old name.

The 2 ways to specify the option are…

1) Manually quote the option

1
<%= in_place_editor 'field_id', :highlight_color => "’#000000’" %>

2) Use the :quoted option

1
<%= in_place_editor 'field_id', :quoted => {:highlight_color => #000000’} %>

Check out our other available plugins at http://agilewebdevelopment.com/plugins/owner/72

New Forum Moderator Role

Along with the existing user roles (league administrator, statistician, scheduler), we’ve now added a new user role for forum moderation. Any user assigned to this role has the ability to edit and delete users forum messages.

Previously a user had to be assigned the league administrator role to have the same abilities, which gave a user full control over all of the websites functions, which is not necessarily a safe option.

Moderate away!

Baseball Support Added

We’ve now added baseball to the list of sports supported by Redzone.

We currently have 3 variations set up, hardball, softball and slo-pitch; so if you have a baseball team, get your league up and running with Redzone today for FREE!

Capistrano and Joyent Accelerator (Open Solaris)

I recently had to deploy a Rails application for a client to a Joyent Accelerator. Paul Ingles has released a Capistrano recipe which helps automate this. I recommend using it.

But even with the recipe, I ran into a couple of snags. The first was with the the myprivateip script that Joyent tells you to use, and the second was Solaris’ ln.

myprivateip

There is a script /opt/csw/bin/myprivateip which is referenced in the mongrel_cluster.yml file they make available. I’d link to the page, but for some reason their how-to pages are all broken today.

Well that script didn’t return anything. It’s supposed to return an ip address.

I changed the script to:

1
2
  #!/bin/sh
  /usr/sbin/ifconfig -a | ggrep -A1 lo0 | grep inet | awk '{print $2}'

Which is just a fancy way to get 127.0.0.1. The mypublicip script seemed to be ok. After fixing that, you’ll want to rerun the cap setup task.

ln

Well I’m not the only one with this problem. Jamie’s blog post helped me get past a problem I was having with Capistrano not updating the symbolic link for the current release. Turns out you’ll want to use the GNU version of ln. On the box I was on though, GNU ln was gln and not ln like in Jamie’s setup, so I took a slightly different approach in order to fix the problem. I created a bin folder in my user’s directory and then put a link to gln like so:

1
  ln -s /opt/csw/bin/gln ~/bin/ln

Next, I put my ~/bin a the front of my path. To do so, I edited .bashrc and .bash_profile (since they both had PATH environment stuff set), but that didn’t solve my problem. There was also an environment file inside the ~/.ssh folder, which gets loaded when you run stuff via ssh, which is what Capistrano does of course. So I added ~/bin to the PATH in that file so it looks something like:

1
PATH=~/bin:/usr/sbin:/usr/bin:<chopped the rest out>

Some other people have replaced a few Capistrano tasks to use gln instead of ln, but that seems sorta nutty to me.

Now Capistrano is cookin with gas.

Rails TimeZone’s

I’ve just added TimeZone support to our Redzone Leagues application and have read a few blog posts about setting up TimeZone’s in rails. One popular article on the subject is found here.

One issue that I came across while I was adding TimeZone support to our app, is that I have time fields in many places in the database that have been created with the local time zone, not UTC, which most articles on the subject seem to assume are already in the database. All of the timestamp fields in my database have no time zone support, which the rails migrations create by default (at least using Postgresql, not sure about MySql, etc.)

The common pattern you’ll see in the articles is similar to this…

1
user.tz.utc_to_local(time)

This assumes the time passed in is already in UTC format, but mine aren’t, they’re in central time.

My solution is to convert the local time to UTC first and then go with the normal conversion used above.

1
user.tz.utc_to_local(TimeZone.default.local_to_utc(time))

So the time from the database is first converted from the local time to UTC (with the local_to_utc call) and then to the time zone associated with the user (with the utc_to_local call).

I added a default method to the TimeZone class that represents the default time zone used in the app.

1
2
3
4
5
class TimeZone
  def self.default
    self["Central Time (US & Canada)"]
  end
end

Now I can leave my database timestamps as is and still achieve the proper conversions for each user.

Redzone Google Maps Integration

Location management has just been made easier with integrated Google maps.

You no longer need to upload an image for your fields, locations, etc. Enter the address of the location and we’ll find it for you (with the help of Google of course).

By clicking on map markers you can view the locations name, address and any other associated information.

You can find out more about the new location manager on the features page.

If you have comments, suggestions on this feature, please post a message in our forums, we’d love to hear from you.

3 New Redzone Features

3 new features have been added to Redzone.

  • An image gallery
  • Player listings
  • Printer friendly schedules

Image Gallery

To find out more about the image gallery, check out our features page

Player Listing

The player listing allows you to view all registered players in the league. A search field is provided in order to easily find a particular player. From the listing, you can preview the users profile picture (if they have one) and click a link to view their full history of stats and teams.

An administrator can enable this feature, but making it visible in the ‘Menus’ section of the admin dashboard.

Printer Friendly Schedules

Schedules can now be displayed in a more printer friendly manner. Simply display the schedule you want to print and press the printer icon located in the top right of the page to load the printer friendly version.