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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:29:35+00:00 2026-06-05T13:29:35+00:00

I am trying to render a comments partial to use with both the blog

  • 0

I am trying to render a comments partial to use with both the blog and video models. Here’s the blog show page asking for the comments partial and passing @blog as the model (I will pass @video on the video’s show page):

<%= render :partial => 'comments/comments', :locals => {:model => @blog} %>

This next code is to order the comments as newest first/oldest first:

<% if @comments.count > 1 %>
  <span class="list_order">
    <%= link_to('Newest First', model, :order => "DESC", :anchor => "comments") + " | " +
      link_to('Oldest First', model, :order => "ASC", :anchor => "comments") %>
  </span>
<% end -%>

This works fine when I say:

link_to('Newest First', blog_path(@blog, :order => "DESC".... etc.)

But I know that you can also just pass:

link_to('Newest First', @blog)

and it will automatically go to the blog show page. So in my code, I’m passing the “model” local, and it does refresh the page, but it does not take my argument for :order or :anchor. How do you pass arguments when using only the instance variable rather than the path on the link_to method?

  • 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-05T13:29:37+00:00Added an answer on June 5, 2026 at 1:29 pm

    Ok, I finally got the chance to ask a friend of mine and found the solution. I needed to use polymorphic paths. So in my example above, the following code works:

    <%= link_to('Newest First', polymorphic_path(model, :order => "DESC", :anchor => "comments") + " | " + link_to('Oldest First', polymorphic_path(model, :order => "ASC", :anchor => "comments") %> 
    

    Then it knows to generate the right path for the variable used. Here’s some info on that:
    http://apidock.com/rails/ActionDispatch/Routing/PolymorphicRoutes/polymorphic_path

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

Sidebar

Related Questions

Just to summarize, I'm trying to make a live page render (browse websites) while
I'm trying to optimize the page render and download and I'm stuck in this
Following this SO post , I am trying to render indented comments using the
i am trying to use django comments on my web application but I get
I am trying to use comments application in my project. I tried to use
I'm trying to create a comments section for a web page. However, the function
I'm trying to do a blog post's comments section where comments are listed below
I am trying to add fb-comments into my html page that is part of
I'm trying to render a collection of comments on Rails 3.1, but only the
I'm trying render the results of surveys from Surveryor gem as a CSV file,

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.