Skip to main content

Posts

Showing posts with the label friendly_id

How to make Search Engine Friendly url in Ruby On Rails?

FreindlyId gem is used to make friendly looking URLs i.e it lets us replace id’s in the URL with the string. It also prevents hacking of the web-page since the id gets hidden by the slug. Before friendly_id: After friendly_id : Here are the simple steps to follow: Step 1: Add gem “friendly_id” to the Gemfile and run “bundle install” on terminal. A] On an existing application : Step 2: Run “rails g migration AddSlugToJobs”. In this case, “slug” is the column name which is adding into existing “jobs” table. Slug : Slug is the part of the URL. It is the slug which makes the URL user friendly. Slug rules states that the string in the URL is separated by dash (-). Its rule also states that the letters in the URL are in lowercase. Step 3: Add the following code to the migration file : In my application,I have migration file “20180109135747_add_slug_to_jobs.rb” in “db/migrate/20180109135747_add_slug_to_jobs.rb”. In this step I am a...