Rolling Windows and Sticky Bytes

<tagline type="clever"/>

Reflections on the Social Web

I thought I would take a break from the technical mumbo-jumbo to reflect on a fascinating thing that happened recently when I added a new feature into the project on which most of these Ruby posts are based.

I don’t usually like to talk about the project or its purpose in specific but I think that would be hard to pull off in this context and still have the post make any impact.

As those of you who know me personally are aware, I will be getting married in a few short weeks to my beautiful fiancée and I’ve been working furiously on hacking together a website to help our guests, both English and Polish — and us — keep track of it all.

In addition to providing information about the wedding itself and allowing people to RSVP online, the intention was to let people make song requests for the reception and, eventually, to upload and download photos of the big day itself. Those were the major features, anyway.

About a week ago, I managed to finish the last of the code required to get the song requests portion of the site going and punched out a notification to everybody who gave their e-mail address that the feature was live. On a whim, I decided to make the song list public, including a simple ranking for how many times a particular song had been requested.

I was not prepared for the response.

Since the song requests feature went live, we’ve had 200 requests come in. People are talking about it. People are excited. Now, instead of this being our wedding reception, I get the sense that people feel that it’s also their wedding reception and that’s amazing.

When we talked to the DJ the first time, he asked us to make him a list of some song suggestions. We met with the DJ over the weekend and when I described the site (and the response) to him, he was amazed. Floored. Totally blown away. I created an account so he could monitor the incoming requests and now he’s watching with glee as the requests come in and rise through the rankings.

I never would have thought that such a small thing would generate such a huge response.

The lesson I’m going to take away from all this? Never underestimate the power of social.

2 Comments »

flash and flash.now

Are the flash messages in your Ruby on Rails application persisting through multiple pages in strange and exciting ways or failing to appear completely?

If so, you may be confusing flash[:warning] = "Some Message" with flash.now[:warning] = "Some Message"!

The key difference is that flash will persist to the next request before being cleared, where flash.now only persists until the end of the current request.

In practice, this means that your controller methods should use flash if your exit point is a redirect (since a new request will be created following the redirect) and should use flash.now if your exit point is a render (since flash.now will be presented to the user during the natural lifespan of the current request, then cleared).

Render — Wrong Way (flash will persist too long):

if song.valid?
  flash[:notice] = "Song saved successfully."
else
  flash[:warning] = "Unable to save song."
end
render :edit_song

Render — Right Way:

if song.valid?
  flash.now[:notice] = "Song saved successfully."
else
  flash.now[:warning] = "Unable to save song."
end
render :edit_song

Redirect — Wrong Way (flash will not appear):

if song.valid?
  flash.now[:notice] = "Song saved successfully."
else
  flash.now[:warning] = "Unable to save song."
end
redirect songs_url

Redirect — Right Way:

if song.valid?
  flash[:notice] = "Song saved successfully."
else
  flash[:warning] = "Unable to save song."
end
redirect songs_url

References: http://stackoverflow.com/questions/4613952/why-flash-message-wont-disappear

No Comments »