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 6027633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:37:16+00:00 2026-05-23T04:37:16+00:00

Im trying to make a side bar for my blog archive that lists out

  • 0

Im trying to make a side bar for my blog archive that lists out all the months for my blog entries, so when you click on a link such as “June 2007” all the blogs from June 07 are loaded.
Heres my link_to

<%= link_to month.first.strftime("%B %Y"), blog_archive_month_path(month.first.strftime("%Y-%m-%d")) %>

month.first is a record I pulled up. Should my controller look something like this?:

@blog_posts = BlogPost.where(:created_at.strftime("%Y-%m-%d") => params[:date]).(:select => "title, id, slug, created_at", :order => "created_at DESC")

I was hoping I could convert the records’ created_by field to a format I could pass in an match but I get an undefined method erro

  • 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-23T04:37:17+00:00Added an answer on May 23, 2026 at 4:37 am

    Basically I agree with what Dan Croak is saying (+1). The only mistake in his answer is that .to_date throws an error if there is not a complete date string in params[:date] (like in his example). So my suggestion would be:

    View:

    <%= link_to month.first.strftime("%B %Y"), blog_archive_month_path(month.first.strftime("%Y-%m-%d")) %>
    

    Controller:

    @blog_posts = BlogPost.
      where(:created_at => params[:date].to_date.beginning_of_month..params[:date].to_date.end_of_month).
      order("created_at desc")
    

    The problem with your original code is that you are trying to call strftime on :created_at, which is not possible.

    Or if you don’t like a full date in your URL, you could do this:

    <%= link_to month.first.strftime("%B %Y"), blog_archive_month_path(month.first.strftime("%Y-%m")) %>
    

    And:

    @blog_posts = BlogPost.
      where(:created_at => "#{params[:date]}-01".to_date.beginning_of_month.."#{params[:date]}-01".to_date.end_of_month).
      order("created_at desc")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a little side-bar menu so people can access area of
If you check out this link (http://noahsdad.com/state-fair-texas-2011/) you'll notice that scrolling side bar to
Hey, I'm having trouble with this side bar I'm trying to make. It wont
I'm trying to make a bar that slides horizontally. If it's positioned left, it
I am trying to make web page which would display two other webpages side
I'm trying to make a fixed vertical navigation on the left hand side of
I'm trying make an entity with doctrine that has three associations with other entities
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
I am trying to make a bar chart using tables, which I have almost
I'm trying to make my app feel more customized with a shaded navigation bar.

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.