How to Save Multiple Checkbox Values to a Database in Rails


Imagine you have a form in your Rails app which is backed by an ActiveRecord model. In this form there are a bunch of checkboxes, the values of which you want to persist to your database. How do you go about handling this scenario?

Read more…

How to Set Up an Apache Virtual Host on Linux Mint


Running Apache on my local machine helps me speed up my web development work. It means that I can use root-relative urls, server-side programming languages (such as PHP) and interface with a database — all without having to upload anything via FTP.

Read more…

Nested attributes and updating without a password in Devise


I’ve spent all day trying to get Devise and nested attributes to play nicely together. This and giving the user the ability to update parts of their profile without providing a password proved kind of tricky. Here’s how I got things working.

Read more…

Authentication with Devise and cancancan in Rails 4.2


This is a beginner level tutorial on how to set up authentication (verifying who you are) and authorization (what you are permitted to do) using Ruby 2.2, Rails 4.2 and two popular Ruby gems: Devise and cancancan.

Read more…

How to install rbenv on Linux Mint 17.1


Last year I wrote about installing rbenv on Linux Mint 16. Back then the installation process as described on the project’s Github page didn’t work for me and, after much frustration,  I ended up installing an older version of rbenv from the repositories.

Recently, I had to reinstall my operating system (upgrading to Mint 17.1) and decided to give the rbenv installation process another try. I’m happy to say that it worked entirely as expected and within a matter of minutes I had two Ruby versions installed on my system and could switch between them at will.

Read more…

How to setup Rails with PostgreSQL on Linux Mint


Rails is database agnostic, meaning that it can talk to different databases without more than configuration changes. Here’s how to install PostgreSQL on Linux Mint 16 and configure it for use with Rails.

Read more…

AJAX beginner’s tutorial


AJAX stands for Asynchronous JavaScript and XML and is used for allowing the client side of an application to communicate with the server side of an application.

This might be necessary in order to update the contents of a drop down menu, or to check the availability of a user name, all without reloading the whole page.

Using AJAX isn’t very hard and in this tutorial I’ll show you how to get up and running.

Read more…

Ignore “Invalid Byte Sequence in UTF-8” error in Ruby


I wrote a simple Ruby script to parse text files and manipulate their content.

This is useful, for example, if you want to replace all occurrences of the phrase “Dr Jones” with “Prof. Jones” across a set of HTML files.

This was working great on Windows, but when I ran it under Linux, I started getting a “invalid byte sequence in UTF-8” error. This is how I solved it.
Read more…

How to validate that two time ranges don’t overlap in JavaScript


I was working on a form for a timekeeping app, where a user is able to enter their time worked, as well as breaks taken.

There is no limit on the amount of breaks that may be taken, but one of the validation requirements is that no two breaks may overlap.

Here’s how I implemented this validation check.

Read more…

How to create a custom filter selector with jQuery


A little jQuery trick I learned recently, was how to create a reusable, custom filter to target specific elements based on their characteristics.

I was kind of surprised that I hadn’t heard of this before, so thought I’d jot it down here, in case it is of use to anyone else.

Read more…

Older Entries Arrow pointing to the right