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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:34:10+00:00 2026-06-02T00:34:10+00:00

I added a has_many :through association (join table) to my houses model, so a

  • 0

I added a has_many :through association (join table) to my houses model, so a house can have multiply categories such as “lastminute”, “house with pool” etc.

I made a custom query, so by example I want all the house in the “lastminute” category (5)

@lastminutes = House.find(:all, :select=>"houses.*", :joins=>"JOIN category_join_tables ON houses.id = category_join_tables.house_id", :conditions=>["category_join_tables.house_id = houses.id AND category_join_tables.category_id = ?", 5])

This work fine in the console.

What is the best approach to get this working on my site. I want url stucture likes this:

domain.com/locale/holidayhouses/lastminutes (house in the lastminute category)
domain.com/locale/holidayhouses/holidayhouses_with_pool (houses in the pool category)

domain.com/locale/lastminutes (houses and appartments in the lastminute category)

Any help would be great!

  • 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-02T00:34:11+00:00Added an answer on June 2, 2026 at 12:34 am

    It is quite easy:

    config/routes.rb:

    match 'search/*categories' => "controller#action"
    

    In your action you get now the categories as an array and only need to parse them into the query. I guess you need the “search” because otherwise rails will take every normal request as categories and redirect you to the action.

    see How to embed multiple tags in Rails routes, like Stack Overflow


    For the l18n part you can do it like

    scope "/:locale" do
      # move all the other routes in here to work with the locale
    end
    

    check out the rails guide on I18N

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

Sidebar

Related Questions

I have a model as follows: Campaign has_many :companies, :through => :contacts There are
I have an Entry model which has many Tag s. Tag s are added
I have three models: Wager, Race, RaceCard and WagerType. I've created a has_many association
I have a model Campaign and the campaign/show goes through a loop of the
I have two model objects: Event Venue Events have Venues. Venues can have 1..*
I have the models User and Group, and the join table Membership which uses
I have two models that can have tags added to them. Player Ticket and
I have the following def in the client model: def cli_full_name [f_name, mi, l_name].join('
I have a question regarding many-to-many relationships, specifically has_many :through associations. All the tutorials
We have a model association that looks something like this: class Example < ActiveRecord::Base

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.