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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:00:51+00:00 2026-06-17T16:00:51+00:00

I have a store with Products. I created a _product.html.erb partial that has a

  • 0

I have a store with Products. I created a _product.html.erb partial that has a summary of the product, and I use it for both the index and show pages.

The issue is, I want the product name to be an <h1> heading in the product show page, but an <h2> on the index page. I want to do this because I have many product on the index page, and I’m not sure if it makes sense to have a large number of <h1>s on the same page. For the show page, I only have that one product, so definitely want to use the <h1>.

The way I did this was with an if/else clause in the partial as below, but it’s a bit messy. Is there a better way to do this?

product/_product.html.erb

<div class="product_partial">
  <% if params[:action] == "show" %>
    <h1><%= product.name %></h1>
  <% else %>
    <h2><%= product.name %></h2>
  <% end %>          
  <h3><%= product.description %></h3>
</div>  

product/show.html.erb

<div class="product_show">
  <%= @product %>
  <%= @product.other_info %>    
</div>

product/index.html.erb

<div class="product_index">
  <%= @products %>
</div>
  • 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-17T16:00:52+00:00Added an answer on June 17, 2026 at 4:00 pm

    Maybe something like this

    product/_product.html.erb

    <div class="product_partial">
        <<%= heading_tag %>><%= product.name %></<%= heading_tag %>>         
        <h3><%= product.description %></h3>
    </div> 
    

    product/show.html.erb

    <div class="product_show">
        <%= render @product, :heading_tag => 'h1' %>
        <%= @product.other_info %>    
    </div>
    

    product/index.html.erb

    <div class="product_index">
       <%= render @products, :heading_tag => 'h2' %>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a standard store schema with an InvoiceLine table that contains Products. I'd
I have an online store. A products page that allows the user to view
In my online store I have a dropdown that lists a number of products.
Lets say you have 2 models... Store :has_many products Product :belongs_to store ..and the
I have id values for products that I need store. Right now they are
I have the following relationship: store.rb -> has_many :products product.rb -> belongs_to :store routes.rb
I have 3 sql tables: In first I store products with key PID. In
I have a hash in which I store the products a customer buys (
I have a list of product edition serial numbers to store in MongoDB, eg,
In my mvc 3 web store app I have this model: Items, Products, Shipping,

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.