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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:38:43+00:00 2026-06-11T01:38:43+00:00

I am working on a rails 3.2 app that basically acts as a blog

  • 0

I am working on a rails 3.2 app that basically acts as a blog with tags.

Tags are related to posts in a has_many :through association. (post have many tags through taggigns)
Don’t know why the app doesn’t have a habtm association since it would have worked the same, but that’s what I have.

The app can now show the list of posts belonging to a tag like this:

class TagsController < ApplicationController

  def show
    @tag = Tag.find(params[:id])    
    @posts = @tag.posts.paginate(page: params[:page], :per_page => 10) 
  end
  ...
end

This way the page example.com/tags/1 will show all the posts with a tag matching ID 1.

What I have to do is modify this app to have checkboxes for tags and to restrict the search for example to posts having both tag 1 and 4.

Can someone please give me an input on where to start or maybe some resources to look for? I think I should use a join but I’m not sure this is the case.

Thank you.

========

EDIT: Thank you for your answers. Anyway, as suggested by ok32, user1083138’s solutions was creating duplicates. At the same time ok32’s one was resulting in empty arrays (probably it’s due to my poor implementation of the tagging system).

I went up with this solution that works just fine:

  def self.tag_query(list)
    Post.joins(:tags).where(:tags => { :name => list } ).having("count(tags.name) = ?", list.count ).group('posts.id')
  end
  • 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-11T01:38:44+00:00Added an answer on June 11, 2026 at 1:38 am

    Yep, JOIN is your friend:

    Post.joins(:tags).where(:tags => { :id => [tag_ids] } )
    

    Check this rails guide as reference.

    Also you have to create\modify views and controllers to show check-boxes and populate “tag_ids” variable.

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

Sidebar

Related Questions

I have a fantasy football league rails app that was working last year and
I have a rails app that is working fine except for one thing. When
I have a working rails app that uses imagemagick commands on my local mac
I have a rails app that was working fine with sqlite but upon switching
I have a Ruby on Rails app that I'm working on and I'm having
I have a House model in my rails app that has_many deals. I am
I'm working on a Rails app that sends data through a form. I want
I'm working on a Rails app that implements some social network features as relationships,
I'm working on a Rails app that existing users can invite additional members to
I am working on a Rails app that allows you to create a configuration

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.