CSS Asset Tagger Rails Plugin
December 3rd, 2009
We’ve released a new plugin for Rails that adds asset timestamps to assets found in an apps stylesheets.
The plugin is available at http://github.com/redlinesoftware/css_asset_tagger
Simply install the plugin and it will tag any assets in your css files with asset timestamps. More information on asset timestamps can be found at http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html
We wrote a previous article on using asset timestamps with nginx, but similar usage applies to Apache as well for example.
The main purpose for writing this plugin is that stylesheets that use images for various things don’t get tagged with the asset timestamps when they’re written as plain old css files. These images can’t make use of expiration techniques very easily without the timestamps. So to make things work as they do with images in rails views, this plugin will add the same timestamps to assets in css files as they are in rails views.
Before…
#navigation_bar {
background-image: url(/images/background-nav.png);
}
After…
#navigation_bar {
background-image: url(/images/background-nav.png?1234567890);
}
If you’re using yslow and some decent expiration on the server and you don’t like seeing images from your css files being shown in your report card, this plugin should make those all go away and hopefully give you a better grade. :)
Redzone Updates: Multiple positions and Team statistics
November 6th, 2009
We’ve just deployed some major updates to Redzone’s statistics. These include support for multiple positions as well as team related statistics in addition to the player statistics that were only supported before.
We’ve added new statistics to some of the sports, so you check for those in the “Statistics Management” section of the admin dashboard. If there are statistics that you don’t see, but would like to see added then just send us an email at support@redzoneleagues.com and let us know what additional stats you would like to see.
The game cards haven’t been updated to support the addition of multiple positions yet, but this will be supported in an upcoming release. If your league doesn’t track stats for more than one position then you’ll be fine with the current game cards.
We’ve made some changes to the standings calculations. Points can now be awarded to teams for Overtime losses. This is a common theme in hockey where shootouts occur.
The forums display a users profile picture (avatar) along with their post count.
Other minor changes and fixes have been made as well and we have a few more quick updates coming in the next few weeks; mainly the addition of some new statistics.
Since this is fairly large update, there may be some minor issues that may appear, so if you notice any inconsistencies or issues with any of the statistic values, please let us know and we’ll correct the issues as soon as we can. You can do so by posting a message in our forums or by sending us an email.
Extending Named Scopes
February 14th, 2009
Quick code tip…
I’m using named_scope with a lambda as the 2nd paramater, but I also want to extend the named_scope with some custom methods.
named_scope :for_league, lambda{|league_id| {league conditions} } do
def default
end
def do_something_custom
end
end
I use the same extended methods in more than one place, so I figured I’d use something similar to the :extend option used with association methods like has_many, but I can’t pass an :extend option if I’m also using a lambda.
The way around this is to just include the methods directly in the block.
module Associations
def default
end
def do_something_custom
end
end
named_scope :for_league, lambda{|league_id| {league conditions} } do
include Associations
end
Works like a charm. Now I can just reuse the Associations module where I need it.
Nginx expiry for Ruby on Rails
January 25th, 2009
Setting the expiry header is a pretty easy way to optimize page loads. Rails helps with this by adding a 10 digit query string that represents the last modified time of the file to assets such as images, stylesheets and javascript files .
Some details on the asset timestamp (the query string of the url) can be viewed in the rails api docs in the Using asset timestamps section.
An example of the paths generated in your views look like this…
/stylesheets/styles.css?1234567890
So if you’re using Nginx, how do we configure things to properly set the expires header?
Read the rest of this entryConverting Subversion repositories to Git
February 24th, 2008
A few friends have asked about converting their Subversion repositories to use Git, but also have a central repo that they can push/pull with which mimics their Subversion setup. Here’s what I do so that I don’t have to repeat myself :)
Read the rest of this entryReverse DNS and email
February 4th, 2008
I’m not sure how I wrote a blog post about sending email and somehow I left out the part about making sure your mail servers have IP addresses that actually reverse properly.
Read the rest of this entrywill_paginate and remote AJAX links
January 30th, 2008
Updated for will_paginate 2.3.x
So you’re using the will_paginate plugin and want to use remote AJAX links. You’re not using the will_paginate plugin? Simply install it with…
script/plugin install git://github.com/mislav/will_paginate.git
or install the gem and specify it in your config/environment.rb file
sudo gem install mislav-will_paginate
config.gem 'mislav-will_paginate', :lib => 'will_paginate', :source => 'http://gems.github.com'
will_paginate is an alternative to the classic_pagination plugin, which is the pagination plugin that basically took the pre Rails 2.0 pagination implementation and packaged it in plugin form. I won’t discuss the differences between the two plugins here, but there’s a good video explaining the two from Railscasts here.
Out of the box, will_paginate doesn’t allow remote AJAX links for page links, so I’ll show you an easy way to add such functionality…
Read the rest of this entryMigrating from Mac OSX Tiger to Leopard
January 4th, 2008
I recently upgraded my Macbook Pro to Leopard, and in the process I took down some notes. Since the MBP is my first Mac, this is also the first time that I’ve had to upgrade the OS. I’m aware that there are upgrade and migration tools that make this whole process quicker and easier, but I’ve heard mixed results about them. I also wanted my install to be fresh, since most of the old school Mac guys seem to go this route.
Read the rest of this entryNew in_place_editor plugin
July 23rd, 2007
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…
<%= 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<%= in_place_editor 'field_id', :highlight_color => "’#000000’" %>
2) Use the :quoted option
<%= in_place_editor 'field_id', :quoted => {:highlight_color => ’#000000’} %>
Check out our other available plugins at http://agilewebdevelopment.com/plugins/owner/72
Capistrano and Joyent Accelerator (Open Solaris)
July 3rd, 2007
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:
#!/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:
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:
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.
Redzone Google Maps Integration
June 16th, 2007
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.
Hotmail blocking emails
April 7th, 2007
Sending emails from a web application can be annoying. Email providers will likely toss your email in the junk folder, if you’re lucky!
Hotmail was rejecting our email recently, but we managed to fix that with the help of SPF.
Read the rest of this entryNew Website Layout
April 4th, 2007
If you’ve visited our site previously, you may notice some changes to our layout and design. If you’re new then welcome to the site, and take my word for it that the site has changed. :)
Our aim was to clean up the look, make things easier to read and keep a consistent look across our Redline and Redzone pages.
We’ve also added a feed to our weblog on the Redline and Redzone pages to make it easier for you to see what we’re up to. We’ll be posting about new and upcoming Redzone features along with various technology related topics.
Along with the recent changes, we’ll be updating the features section of our Redzone leagues site to better showcase what’s available in the product. Also keep an eye out for some videos and walkthroughs in the near future.
Let us know what you think of the new changes by leaving a comment or let us know what you’d like to see.
