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

  • Home
  • SEARCH
  • 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 550253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:16:08+00:00 2026-05-13T11:16:08+00:00

I’ve got a blogs_controller with a Blog resource, so I’ve got your typical routes

  • 0

I’ve got a blogs_controller with a Blog resource, so I’ve got your typical routes right now as follows:

/blogs/new
/blogs/1
/blogs/1/edit #etc

But here’s what I want:

/blogs/new
/blogs/2010/01/08/1-to_param-or-something
/blogs/2010/01/08/1-to_param-or-something/edit #etc
...
/blogs/2010/01 # all posts for January 2010, but how to specify custom action?

I know that I can do this with a combination of map.resources and map.connect, but I’ve got a lot of views that link to other pages via “new_blog_path” etc and I don’t want to have to go and edit those. Is this possible with map.resources alone? It might not be easy, but I’m not against being clever. I was thinking of something like:

map.resources :blogs, :path_prefix => ':year/:month/:day', :requirements => {:year => /\d{4}/, :month => /\d{1,2}/, :day => /\d{1,2}/}

But I’m not sure how that works with actions like ‘new’ or ‘create’, and it also gives me a route like /2010/01/08/blogs/1-to_param-etc with blogs in the middle of the URL.

So, is there a clever solution that I’m missing, or do I need to go the map.connect route?

  • 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-05-13T11:16:08+00:00Added an answer on May 13, 2026 at 11:16 am

    I ran into the same issue recently, and, while this may not be what you’re looking for, this is what I’ve done to take care of it:

    config/routes.rb:

    map.entry_permalink 'blog/:year/:month/:day/:slug',
                        :controller => 'blog_entries',
                        :action     => 'show',
                        :year       => /(19|20)\d{2}/,
                        :month      => /[01]?\d/,
                        :day        => /[0-3]?\d/
    

    blog_entries_controller.rb:

    def show
      @blog_entry = BlogEntry.find_by_permalink(params[:slug])
    end
    

    blog_entries_helper.rb:

    def entry_permalink(e)
      d = e.created_at
      entry_permalink_path :year => d.year, :month => d.month, :day => d.day, :slug => e.permalink
    end
    

    _entry.html.erb:

    <h2><%= link_to(entry.title, entry_permalink(entry)) %></h2>
    

    and for the sake of completeness:

    blog_entry.rb:

    before_save :create_permalink
    
    #...
    
    private
    
    def create_permalink
      self.permalink = title.to_url
    end
    

    The #to_url method comes from rsl’s Stringex.

    I’m still new to Rails (and programming) myself, but this is probably the simplest way to go about it. This isn’t a RESTful way of going about things so you don’t gain the benefit of map.resources, unfortunately.

    I’m not sure (because I haven’t tried it), but you might be able to create the appropriate helpers in application_helper.rb to override the default route helpers for blog_path, et al. If that works, then you won’t have to change any of your view code.

    If you’re feeling adventurous, you might check out Routing Filter. I considered using it, but it seems like overkill for this task.

    Also, if you’re not aware, two things you can do to test your routes/paths from within script/console:

    rs = ActionController::Routing::Routes
    rs.recognize_path '/blog/2010/1/10/entry-title'
    

    and

    app.blog_entry_path(@entry)
    

    Good luck!

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

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
i got an object with contents of html markup in it, for example: string
I've got a string that has curly quotes in it. I'd like to replace
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a JSP page retrieving data and when single or double quotes are
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.