- ARCHIVE / Rails
- Another super-tiny Rails plugin: classy_inputs
Good lord do I ever hate input tags. (YUI hates them too, but I’ll leave that story for another time). All the different types should really have been different tag names, and they are a total pain to use with CSS. As such, I used to end up doing tedious stuff like adding a :class [...]
- Tiny Sunday coding project: has_password
Just a little announcement about something I cooked up this afternoon. It’s nothing ground-breaking but might save you a little time. Basically, I was getting super-tired of writing the same authentication code for every project so I extracted it into a plugin called has_password. Install like so:
ruby script/plugin install git://github.com/jcoglan/has_password
Now, this plugin is tiny and [...] - Quick and dirty icons in ActionView
Tiny tiny Rails tip: you can use method_missing to make using icon sets easier when writing Rails views. Behold:
module ApplicationHelperdef method_missing(sym, *args)
super unless sym.to_s =~ /_icon$/
image_tag(”silk/#{sym.to_s.gsub(/_icon$/, ”)}.png”)
endend
Now the following call:
<%= pencil_icon %>
produces this image tag:
<img src=”/images/silk/pencil.png” /> - On-demand thumbnails with Rails and rmagick
My, it’s been a while since I wrote a Rails tutorial. I’m going to come back from the land of esoteric JavaScript techniques for a minute and talk about something you might actually want to use in real life.
Many people, when writing an app that uses image uploads in some way, like to generate thumbnails [...] - Let’s get committed
Right, I know I said I’d do this a long time ago, but I just got round to checking up on some of my Rails patches with the hopes of persuading one or two of you that they might be worth supporting and getting committed to the core. This post concerns a couple of patches [...]
- Announcing Holly
After some discussion at work about how to manage JavaScript dependencies in our CMS, I decided to write a quick Rails plugin for doing just that. It’s called Holly, and it lets you use special comments inside script and CSS files to declare their dependencies. Whenever you use javascript_include_tag or stylesheet_link_tag, Holly inspects the dependencies [...]
- PackR won’t touch your $supers
Another quick update: PackR received an update today that means that when you use its :shrink_vars mode, it won’t minify any variables called $super. In Prototype, $super is used to implement inheritance and your class definitions will break if you change its name.
I didn’t really want to make PackR inconsistent with Dean’s original, but without [...] - PackR gem now available
Update: the gem seems to be up on RubyForge now, so just gem install packr and you’re all set.
At the request of Aman Gupta (again!) PackR is now available as a gem. I’ve not got myself all set up on RubyForge yet, but in the meantime you can download the gem from my subversion repository. [...] - PackR, now with class methods
Quick note: at the suggestion of Aman Gupta, PackR now supports Packr.pack, Packr.minify and Packr.pack_file as class methods, so you don’t need to create an instance of PackR before doing anything. Originally, I wanted PackR’s design to mirror the JavaScript version to make maintainance easier, but these methods are a tiny addition so I’m happy [...]
- Announcing PackR
I’ve no idea who may have done this already, but I certainly coundn’t find anyone who had in five minutes of searching. I’ve written a Ruby port of Dean Edwards’ Packer, and released it as a Rails plugin. It includes a rake task for batch-processing the scripts in your application. Install like so:
ruby script/plugin install
[...]