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.
Grades
a
95.0%
- 5 Unlocks
- 361 Total Reads
- 12 minutes Est. Learning Time
Top Rated
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!