Take advantage of Rails data attribute transformation to clean up your UJS

As a Rails developer, you’ll almost certainly need to do some unobtrusive Javascript in your applications - in fact, if you use Rails’ jquery-ujs gem, it’s almost encouraged! Without writing any script yourself at all, you can have a form button that disables itself with a message while the form is submitted by simply constructing your button like so: <%=...

Finding records by ID with Ransack

Ransack is one of my go-to Rubygems, especially for admin applications. It provides a really simple interface to building up complex filtering and ‘searching’ of many records. Check out the README for more information about how it all works - this post covers a specific problem case of Ransack. In Rails, we are often subtely educated that the ID of...

The curses of proprietary technologies

As a web developer, I’ve got a pretty good pick of websites - I know what companies are prepared to stick with tried and tested technologies, and combine it with just enough new stuff to make browsing their site pleasant and easy to do. Every now and then though, I’m forced out of my comfort zone, and need to find...

Publishing with ActiveRecord: a guide to encapsulated code

It’s not at all uncommon to be asked by a client “So, I’d really like to be able to edit that bit of the page just there - can we do that?”. The answer, of course, is yes, but managing content has no end of complexities. Just one of these many is publishing - that is, controlling content, where it...

HTML5 Notifications

On the Spot is a pet project that I tend to develop with bleeding-edge features in mind - something a bit more volatile than Latter, which is used heavily enough to justify a more cautious development process. In this post, I’m going to detail how I added HTML5 notifications to On the Spot, the upsides and downsides, and the Coffeescript...

Secret Keeping with Rails

Ever needed to store some secrets in Rails that you don’t want to share with the world? Yeah, same! In this post, I’m going to outline a really simple way to store your application’s secrets in a file called config/secrets.yml. Rails configuration and you First of all, let’s discuss exactly how this is going to work. If you’ve even configured...

Redesigning for readability - a retrospective

I’ll be the first to admit that I’m not that great at design, especially typography and detailed elements. I’m just one of those people who can see what they want in their heads just fine, but something just goes…wrong…between the head and the page. In this post, I’m going to explain some of the lessons I learned while focussing on...

Process configuration management with Foreman

Often in the Rails projects I build, I have a need to store configuration that I don’t really want to have in my code. The most obvious way to do this is to either store the configuration in a YAML file (e.g. config/settings.yml), or in environment variables. Foreman is Heroku’s answer to these types of configuration challenges. It is used...