Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8208289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:17:23+00:00 2026-06-07T09:17:23+00:00

I am using friendly_id as follows: class Page < ActiveRecord::Base extend FriendlyId friendly_id :title,

  • 0

I am using friendly_id as follows:

class Page < ActiveRecord::Base
  extend FriendlyId
  friendly_id :title, :use => [:slugged, :history]
end

I would like to be able to set the slug (i.e. be able to set a custom URL) without changing the title and maintaining old slugs in history.

Is there a straightforward way to do this using friendly_id or will I need to interact with the history table?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T09:17:25+00:00Added an answer on June 7, 2026 at 9:17 am

    I accomplished this by adding an instance attribute url_seed:

    class Page < ActiveRecord::Base
      extend FriendlyId
      friendly_id :slug_for_url, :use => [:slugged, :history]
    
      attr_accessible :title, :url_seed
      attr_accessor :url_seed
    
      def slug_for_url
        self.url_seed.blank? ? self.title : self.url_seed
      end
    end
    

    Now, on save, if url_seed is set, friendly_id uses the custom URL text to set the URL. Works like a charm 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a mobile-friendly website using jQuery Mobile but would like to do
I'm using IPB forums. I managed to use friendly urls with nginx server conf
I'm using the friendly_id gem. I also have my routes nested: # config/routes.rb map.resources
I'm using the friendly_id plugin to generate SEO-friendly URLS for some of my models.
I'm using this to redirect to the home page if the post doesn't exist:
I'm using the friendly_id gem . There's a rake task for deleting old slugs
I would like to use create a rails route for a user's open id.
I have a Rails blog using friendly_id for creating custom urls. The blog has
Using: Rails: 3.0.3 Friendly_id: 3.2.1 I am building a website with (currently) two locales,
Using: Rails 3.0.3 Friendly_id: 4.0.0.beta11 I have create a fully working development version of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.