Learn How to Create Search Engine Friendly urls in Rails

with codediode

X7z4h1uiquw3e0dp13xd?cache=true

Search Friendly URL Lesson Details

In this lesson, I will show you how to code search friendly urls for Ruby on Rails app. The lesson includes the raw code and instructions for setting up your model. I break down this tutorial into 3 simple steps that can be completed in less than 10 minutes. In addition, I provide a link to my blog where you can learn about this topic. 

Other Important Info

  • This tutorial uses Ruby on Rails 4.2 and Ruby 2.2 (but works with any version of rails 4)
  • There are some minor limitations, which will be mentioned in the lesson
  • I'm making this lesson free!

Add the Permalink Attribute to the Database

Note: For this lesson, we are assuming we have a Post model that has a :title attribute.

Step 1 - Create a Permalink Attribute

In order to generate search friendly URLs, we must create an attribute on the model to hold the permalink. From the console, run the following commands: 

$ rails g migration AddPermalinkToPost permalink:string
$ rake db:migrate

Code the Model and Controller

This Section is Locked!

Unlock this lesson for free to view all sections.

Signup and Unlock for free

Grades

b

Graded

Solid info, but a little light on content. This did not fit perfectly with my scenario, but it was still helpful. A few tweaks to my rails routing configuration and I was able to get it working perfectly. But hey, thanks for the free lesson!

Av 1 6de6c68998209aa73ceb4952e20f35de3e0e321b80400da723550f17f6175432
a

Graded

Quite helpful and easy to implement.

Av 6 35ca29fbea030fa2382540a06151508af22e7ca546b320764dd1caa63c096f8b
a 95.0%
Technology Code

  • 5 Unlocks
  • 131 Total Reads
  • 12 minutes Est. Learning Time
Top Rated