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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:59:40+00:00 2026-06-10T03:59:40+00:00

I need to generate a custom engine like products which are categorized in Brands

  • 0

I need to generate a custom engine like products which
are categorized in Brands and Categories:

Products:

  • Category 1

—–Product 1 /the same product in brand 1/

—–Product 2

— Category 2

— Category 3

Brands:

  • Brand 1

—–Product 1 /the same product in category 1/

—–Product 2

  • Brand 2

  • Brand 3

What are the best scenarios to the above.

I did the following to achieve my needs:

1- Generated a new engine called category

$ rails generate refinery_engine category name:string image:image
$ bundle install
$ rails generate refinerycms_categories

2- Generated another engine called brand

$ rails generate refinery_engine brand name:string image:image
$ bundle install
$ rails generate refinerycms_brands
$ rake db:migrate

3- Generated an third engine called product and genreated that inside
category and brand engines:

$ rails generate refinery_engine product category:engine brand:engine
name:string category_id:integer brand_id:integer number:string
quantity:integer brief:string description:text image:image
catalog:resource
$ bundle install
$ rails generate refinerycms_categories products
$ rake db:migrate

4- I’ve edited the following files inside /vendor/engines/categories/
app/models:

category.rb

has_many :products

product.rb

belongs_to :category
belongs_to :brand

5- Also I’ve edited /vendor/engines/brands/app/models/brand.rb:

has_many :products

6- I’ve edited In _form.html.erb :category_id and :brand_id to make an
HTML tag:

<div class='field'>
<%= f.label :category_id -%>
<%= collection_select(:product, :category_id, Category.all, :id, :name) %>
</div>

<div class='field'>
<%= f.label :brand_id -%>
<%= collection_select(:product, :brand_id, Brand.all, :id, :name)%>
</div>

7-In the front-end product section I see all the products when I click
on a product Category and Brand are showing ids not the names. I need
to display names rather than ids.

8- When I click on categories it lists only categories without showing
the products inside it…. The same applies for brands. So how can I
list the products which are associated with categories and brands
inside each of them..

Thank you in advance for your support guys… I appreciate your help.

  • 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-10T03:59:42+00:00Added an answer on June 10, 2026 at 3:59 am

    Creating a separate category and brands model doesn’t make much sense to me. I would rather have them as fields in the product table and write a helper to get all unique categories and brands.
    eg:

    def get_categories
      Product.pluck(:category).uniq
    end
    

    To filter products by categories: (this would replace the select tag for categories in your _form.html.erb)

    options_for_select(get_categories)
    

    To select products belonging to the same category, you can do something like:

    @products = Product.where("category=?",params[:category])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically need to generate custom(some different then yes no) messeges(alert) in JS , how
I'm working on a Nopcommerce, and need to generate Invoice (custom made not as
I need to generate custom SIDs for users in my web application for use
For a customer we need to generate detailed test reports for integration tests which
I need to generate a custom button through code, this is how i am
I need generate action links outside controllers. I can use Html.Action in Views, Url.Action
I need to generate a couple of objects from lists in Javascript. In Python,
I need to generate such pattern for my input, for example: +375 29 911-91-91
I need to generate report that will show number of new / changed rows
I need to generate css based on client queries. I use the @import url()

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.