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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:42:18+00:00 2026-05-15T08:42:18+00:00

Until now, I’ve been using acts_as_taggable_on plugin for tagging announcements. That plugin creates the

  • 0

Until now, I’ve been using acts_as_taggable_on plugin for tagging announcements.

That plugin creates the following tables:

taggings: relates tags and announcements table(for the tagged item, it has a field called taggable_id, which I rename to “announcement_id” for what I’ll explain below).

tags: has the tag ids and names.

The other day, I discovered that I had no way of getting the announcements tagged with a certain tag, but doing Announcement.tagged_with(tag_name), and I don’t want to search by name, but for id.

So, as I’m using almost nothing of the functionality in that plugin, I decided to create the models for taggings and tags tables, to accomplish this: Announcement.tags.

The models’ relationships look as following:

EDIT:

class Tagging < ActiveRecord::Base
  belongs_to :announcement
  belongs_to :tag
end

class Tag < ActiveRecord::Base
  has_many :taggings
  has_many :announcements, :through => :taggings
end

class Announcement < ActiveRecord::Base
  has_many :taggings
  has_many :tags, :through => :taggings

Why can’t I execute the command Announcement.tags? Because when I try, I get

undefined method `tags’

  • 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-15T08:42:18+00:00Added an answer on May 15, 2026 at 8:42 am

    What you’ve actually posted is that you’ve tried Announcement.tags. But tags would be a method on an Announcement instance, and that’s calling it as a method on the Announcement class, which won’t work.

    Assuming you’re actually calling an_announce.tags, you also need Announcement and Tag to have many taggings – like so:

    class Announcement < ActiveRecord::Base
      has_many :taggings
      has_many :tags, :through => :taggings
    end
    
    class Tag < ActiveRecord::Base
      has_many :taggings
      has_many :announcements, :through => :taggings
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Until now I've been used to using DAOs to retrieve information from databases. Other
I'm learning scheme and until now have been using guile. I'm really just learning
Until now, I believed that -(void)startToDoSomethingWithThis:(That*)thing andThat:(That*)otherThing has the following method signature, which is
Up until now I've been deploying Rails apps to our Apache/Passenger setup using a
Up until now I've only been using orchestrations in my BizTalk application and it's
Until now I've been using Indy 10 without issues but after recent problem with
I've got a CodeIgniter project that until now has been only run remotely (it
Until now, I've been handling extensions by defining a placeholder element that has name
Until now I have been using XML parsing in my application, but I recently
Until now, I've been using the <iframe> tag to load things like headers/footers/navbars into

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.