0

I'm using the Monologue gem for blogging on my rails 4.0.4 app. I need to find all the posts that don't have a specific tag. The following attempts at trying to do this are not working:

Monologue::Post.includes(:taggings).references(:taggings).where.not(taggings: { tag_id: 1 })

I get what looks to be the proper query but about halfway down it shows:

SQLite3::SQLException: no such column: taggings.tag_id: SELECT "monologue_posts"

What am I doing wrong??

NomNomCameron
  • 419
  • 5
  • 14

1 Answers1

1

Looks like the table name is monologue_taggings not taggings.

Try this?

Monologue::Post.includes(:taggings)
               .references(:taggings)
               .where.not(monologue_taggings: { tag_id: 1 })
Nick Veys
  • 23,458
  • 4
  • 47
  • 64
  • Bingo. Thank you so much. I thought "monologue" was prepended to "taggings" because all the monologue tables are (because it's mounted as an engine) so I thought rails would figure that out :p – NomNomCameron Aug 24 '14 at 17:16
  • Yeah, unfortunately it doesn't. I've been bitten by the same inconsistency so I feel your pain. :) – Nick Veys Aug 25 '14 at 15:39