Monthly Archives: February 2014

Vanity URLs with Rails

Rails default URL construction is very straightforward:

www.domain.com/controller/:id

which, in the specific case of a blog with one or more users, translates into e.g.

www.blog.com/users/1

There is obviously nothing wrong with that in terms of functionality, but the impersonal URLs are more difficult to remember, aren’t very useful for SEO, and just don’t have that warm personal touch that a personalized URL offers. So, how to go from

.../users/1

to

.../users/gemfile

?

The answer is not especially complicated but more cumbersome than one might think. (A very quick method is shown at the end of the article.) Continue reading

Advertisements

GitHub gists in a Rails blog

It did indeed occur to me that a blog about learning Rails could be coded by me in Rails instead of relying on WordPress to do all the heavy lifting. In the process of coding said blog app, an issue came up regarding formatting markup contained within posts. By default, Rails escapes everything, meaning that after typing “<i>word</i>” into the body of a new post, it is rendered exactly as “<i>word</i>” and not “word” as intended by the author. Continue reading

Tagged , , ,

Explaining to myself: Sessions

After the third or fourth time through the Rails Tutorial, I’m finally starting to get a good grip on the way Rails sessions operate, as well as on the code that drives them. The bulk of my confusion came from sessions_helper.rb, reproduced here in its entirety: Continue reading

Tagged , ,