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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:53:34+00:00 2026-05-20T18:53:34+00:00

I have a Ruby on Rails model that has quite a few HABTM relationships.

  • 0

I have a Ruby on Rails model that has quite a few HABTM relationships. Essentially, i’m making a video sharing site themed around skateboarding for a client. Each video has many attirbutes through HABTM: Location, Skateboarders, tags, location, music, equipment, spot, region, etc… And it also has a few class attributes that are significant: Title, description, etc…

The idea here is my client would like a “Related Videos” feed by each video player, using all of the formerly mentioned descriptive data. Furthermore, the information should be weighted (similar titles take precedence over similar tags).

I was trying to find a good way implement Google SiteSearch to handle the grunt work, but can’t find a good search term syntax ie:

inurl: example.com/videos related:example.com/videos/4638872 

Which doesn’t actually work, unfortunately…

  • 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-20T18:53:34+00:00Added an answer on May 20, 2026 at 6:53 pm

    Solved this by using ferret to do a keyword explode search.

    def related
        string = self.name + " " + self.tag_name + " " + self.skateboarder_name + " " + self.category_name + " " + self.editor_name
        #probably could have used "join" there...
        s = "*" + string.gsub(" ", "* OR *") + "*"
        relates = Video.find_with_ferret(s)
        #takes out duplicates and gices 10 to choose from
        while relates.count <= 10
            relates << Video.random
            relates = relates.uniq
        end
        #take out original video
        relates = relates - [Video.find(self.id)]
        #send back with "middle data"... for some reason i thought this might be more accurate....
        return relates[1..8]
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have already built a rails app that has several users and an image
We have a model association that looks something like this: class Example < ActiveRecord::Base
Just starting to learn Ruby on Rails. I'm using RoR 3. I have read
I am using Ruby on Rails 3 and I am trying to use an
I am using Ruby on Rails 3 and I am trying to submit namespaced
I am using Ruby on Rails 3 and I am trying to retrieve some
I have a client who wants to bulk-upload photo files to her existing Ruby
I am converting a php project into ruby on rails. The previous project used
This is it, for all the marbles, if I can get this issue solved

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.