Dec 09

Date published: 12-9-2013

Rails version: 4.0.0

URLs and readability

One consideration when creating web sites with Rails that a developer should consider is how easy it is to navigate the site. One convention Rails uses for URLs is to have a path that includes the name of the class from the model along with the id of whichever specific item we want to look at. This is great for Rails as it makes it obvious which item we want to search for in our model, but from a human readability standpoint it’s not that great. This tutorial will show you what to add to your application to make your URLs more readable.

Pretty URLs

Pretty URLs

Continue reading »

Tagged with:
Nov 25

Date published: 11-25-2013

Rails version: 4.0.0

File upload

Web sites are a very visual form of communication, and so it’s not that uncommon for users to want to add photographs to their sites. Most sites let you load an avatar for your user page, and some sites like flickr and Photobucket are based around hosting images. In this tutorial, we’re going to use a gem called Carrierwave upload photos and display them on a web page.

Photo upload

Photo upload

Continue reading »

Tagged with:
Nov 11

Date published: 11-11-2013

Rails version: 4.0.0

User authentication

Almost every web site these days requires users to log in before accessing content on the site, so it’s important for web developers to understand user authentication. Rails has several open source options for user authentication, but the most popular and one of the most versatile is called Devise. In this tutorial, I’ll show how to install Devise and setup basic authentication to allow the user to log in with their email address. Once we understand how Devise works, we’ll expand it so that with only one field users can log in with either their username or email address.

Sign up screen

Sign up screen

Continue reading »

Tagged with:
Oct 28

Date published: 10-28-2013

Rails version: 4.0.0

Sorting lists

One thing that comes up fairly often on web sites is the need to sort lists of items. A good example of this would be a wishlist like on the Steam web site. It lets you add items to your wishlist and then sort them so they will be shown in whatever order you prefer. Rails offers a very easy way to create sortable lists, and I’ll show you how to set it up for a basic todo list.

Steam wishlist

Steam wishlist

Continue reading »

Tagged with:
Oct 14

Date published: 10-14-2013

Rails version: 4.0.0

Installing a natural text editor

In the tutorial from last week, we created an application that let the user write messages on a graffiti wall. We only let the user write a basic message, so what happens if we add some HTML to the message when we write it? Start the Rails server and give it a try, and you’ll notice that any HTML tags you write in the message won’t be interpreted but will be printed exactly as you wrote them on the wall. We’d like to modify our program so that the user can add things like bolding or changing the background color. In this tutorial, I’ll show you how to add a text editor called CKEditor to your Rails application. Continue reading »

Tagged with:
Sep 30

Date published: 9-30-2013

Rails version: 4.0.0

What does automagically mean?

One of the first descriptions I heard about Rails was that it handled things automagically to make programming web sites quicker and easier. I’d never heard the term before, so I looked it up online and found this definition: automatically; in a way that is hidden from or not understood by the user, and in that sense, apparently “magical.” That was the way I felt when I worked through tutorials, and even though I’d written the program myself, I had no idea what it was doing to make it work in the background. The worst part was that even after learning how to do something, I couldn’t just sit down and write my own program using what I’d just learned. Usually the new program I was trying to make would break in some way, and I wouldn’t know what was broken or how to fix it because too much was happening automagically for me to know where to even start. Continue reading »

Tagged with:
Sep 16

Date published: 9-16-2013

Rails version: 4.0.0

What is Bootstrap?

Bootstrap was developed by a group at Twitter to provide a consistent graphical framework for their web sites. Since it was released, it’s become one of the most popular suites of graphical tools for web site development. It includes CSS templates, grid layout classes, and responsive elements that make it easy to develop one site that can be easily viewed on screens of all sizes. Perhaps the biggest benefit to adding it to a Rails project is the fact that there is already a gem that includes all the functionality of Bootstrap. It’s a good idea when learning how to program a new language to have a basic project template that you can build upon for any new projects you want to make. This is doubly true in Ruby on Rails where every project has a visual component, so having a basic web site template to build off of is really important. Continue reading »

Tagged with:
preload preload preload