Posted by Chris Anderton on August 11th, 2008 @ 13:37 – 0 comments
Updated on August 11th, 2008 @ 13:41
Tagged with rails
One of the projects we’re working on needs to be able to publish images to Flickr. Rather than re-invent the wheel a quick search on RubyForge and GitHub turned up a number existing Flickr libraries for Ruby. After considering future requirements, we decided to go with flickr_fu.
There was just one teeny tiny problem: uploads to Flickr within flickr_fu were broken, as we discovered when we looked at the comments in the Flickr::Uploader class:
# NOT WORKING ... FILE UPLOADS IN NET::HTTP IS TEH SUCK
A fork, a clone and a few tweaks later and we’ve got uploads working. The changes are currently in our fork but I’ll also be submitting them upstream after a little more testing.
Discuss this entry
Posted by Rob Anderton on August 6th, 2008 @ 16:36 – 0 comments
Updated on August 6th, 2008 @ 16:37
Tagged with rails
There are currently a couple of web-based surveys being carried out that you may want to take a look at. First up is the survey for people who make websites 2008 aimed at anyone involved in web development from designers to Ruby coders from the guys at A List Apart.
Nearly 33,000 people took part in 2007 and it will be interesting to see what has changed and what has remained the same in terms of salary, experience, education and working conditions over the last year.
The second comes from HAML creator Hampton Catlin in the form of the more Ruby-centric Hampton’s Ruby Survey 2008. At the time of writing over 900 people have responded, so if you haven’t already, now’s the time to get your entry in.
The survey covers Ruby and Javascript frameworks, testing, interpreters and in a bizarre twist ends with religious beliefs. It will certainly be interesting to discover if the Ruby community is big on new-age spirituality or is just a godless bunch of coders!
Discuss this entry
Posted by Rob Anderton on August 3rd, 2008 @ 16:10 – 2 comments
Updated on August 4th, 2008 @ 16:51
Tagged with rails
Mislav’s will_paginate plugin (and Gem) has become the de facto standard for pagination in Rails, replacing the often derided classic pagination from the dark days before Rails 2.0. If you haven’t used will_paginate before then Ryan Bates’ RailsCast is a good introduction, although be warned that it is just over a year old and there have been a number of changes to the plugin in that time (the current version is 2.3.2).
Read more of this entry
Posted by Rob Anderton on July 14th, 2008 @ 12:52 – 1 comment
Updated on July 14th, 2008 @ 12:57
Tagged with rails
When the default session store for Rails was changed to use cookies last year it caused quite a furore: "It’s not secret! It’s not safe!" The truth is it was never meant to be: in most circumstances you shouldn’t really be storing data in cookies that need to be protected so strongly. But I don’t really want to re-open that can of worms! Instead I want to look at a different cookie-related situation that arose during some optimisation work I’ve been doing on an existing Rails application.
The scenario is straightforward enough: the application stores a numeric record ID in a persistent cookie that, while perfectly safe to be seen by users, shouldn’t be changed by them. The solution currently used in the application is equally straightforward: the data is encrypted (using the EzCryto gem and AES encryption) before being written to the cookie, and then decrypted when the data is read back in.
In situations where cookie contents really shouldn’t be seen by users then encryption is the way to go (unless of course you can find a way of not using a cookie at all), however for a simple numeric ID where tampering is the only thing we need to protect against then it seems like overkill. A better solution is to take inspiration from the Rails cookie session store and use a HMAC.
Read more of this entry
Posted by Rob Anderton on June 9th, 2008 @ 18:00 – 21 comments
Updated on July 9th, 2008 @ 19:30
Tagged with rails
Rails 2.1 has just been out a week and so far something that seems to have passed most people by is that it now includes much better caching capabilities, including built-in support for memcached.
Last week I reached the point with an application where I needed to cache some models in memory to get a performance boost and decided to check out the current status of plugins like cache_fu and CachedModel to make sure they’d work with Rails 2.1. It was completely by accident that I stumbled across this innocent looking commit by DHH from start of this year and realised that Rails already had everything I needed!
Read more of this entry
Posted by Rob Anderton on June 2nd, 2008 @ 15:23 – 2 comments
Updated on June 10th, 2008 @ 12:12
Tagged with rails
Ok, so I’m starting a new Rails application, I’ve spent some time refining my database, I’ve considered storage requirements and performance when choosing the data types for my fields and now I’m ready to create some migrations to implement my design.
And then I’m reminded that, lovely though Rails migrations are, there are two things that really bug me about them: they create signed primary keys and they don’t allow me to easily create unsigned integer columns.
It’s been discussed before, dismissed as an ‘uncommon requirement’ (probably because MySQL is, as far as I know, the only database that uses unsigned integers) and, as far as I can tell, not a lot more has happened. So, while sat out in the garden, enjoying a sunny Saturday afternoon, I grabbed edge Rails from GitHub and decided I’d see if I could do something about it (how’s that for geekyness?!)
Read more of this entry
Posted by Chris Anderton on May 21st, 2008 @ 10:37 – 0 comments
Updated on June 10th, 2008 @ 12:13
Tagged with rails
Following on from Rob's Rails plugin round-up a few months back then another plugin has repeatedly found it's way into our projects - sql_logging.
Read more of this entry
Posted by Rob Anderton on April 21st, 2008 @ 10:48 – 0 comments
Updated on June 10th, 2008 @ 12:13
Tagged with rails
The default Rails behaviour for highlighting form fields with errors is to wrap them in a div, so:
<div>
<%= f.label(:email) %>
<%= f.text_field(:email, :size => '30') %>
</div>
Becomes:
<div>
<div class="fieldWithErrors"><label for="user_email">Email</label></div>
<div class="fieldWithErrors"><input id="user_email" name="user[email]" size="30" type="text" value="" /></div>
</div>
This is great when knocking together a quick prototype but as your site evolves you’ll probably want to customise it. This can be done very easily by using ActionView::Base.field_error_proc, assign a Proc to it either in your environment.rb or, if you’re a modern thinker, in an initializer and you’re good to go.
Read more of this entry
Posted by Chris Anderton on April 14th, 2008 @ 14:23 – 0 comments
Updated on April 14th, 2008 @ 14:24
Tagged with rails
Good news - persistent storage for EC2 is on it's way - it's already in private beta and will be 'publicly available later this year'.
Read more of this entry
Posted by Chris Anderton on April 14th, 2008 @ 12:27 – 0 comments
Updated on April 14th, 2008 @ 12:28
Tagged with rails
About a month ago Gregory Brown created a buzz with his blog post about working on open source projects for money. Gregory opens with a "Here’s a crazy idea" - but then outlined an idea that was pretty fresh, and not crazy at all (in my book!). This evolved into a wiki around the subject - an interesting read.
As is usual, it created a lot of discussion on blog sites and also fed into talks of a similar nature that had been happening at TheWebFellas HQ.
Read more of this entry