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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:27:18+00:00 2026-06-01T05:27:18+00:00

If I have 3 models… Post, Logo_Category and Logo and 5 tables posts, logos,

  • 0

If I have 3 models…

Post, Logo_Category and Logo

and 5 tables

posts, logos, logo_categories, logos_posts and logos_categories_posts

A post can have any number of logos from any number of logo_categories. I have started down the line with HABTM but I think I may have chosen the wrong path in terms of my schema.

Anyone have any idea what is the best way of associating these models?

Cheers

EDIT

Sorry guys, I thought I had solved this issue but…

In line with what Paul suggested I have now changed my associations to the following.

POST.erb

has_and_belongs_to_many :logos
has_many :logo_categories, :through => :logos  

LOGO.erb

  belongs_to :logo_category
  has_and_belongs_to_many :posts

LOGO_CATEGORY.erb

has_many :logos
has_and_belongs_to_many :posts

and my tables are now…

posts (id) , logos (id), logos_posts (id, logo_id, logo_category_id),
logo_categories (id)

My post _form loads fine and all of the logos and logo_categories are loaded with the correct values and checked/unchecked (when editing a post) correctly.

I can check a new logo or uncheck an existing one and that records fine. However, if I alter a logo_category I get the following error!

Cannot modify association ‘Post#logo_categories’ because it goes
through more than one other association.

Any ideas?

  • 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-01T05:27:19+00:00Added an answer on June 1, 2026 at 5:27 am

    For your table:

    [posts] 1--n [post_logos] n--1 [logo] n--1 [logo_category]
    
    • Each post has one row in post table with a unique post_id
    • Each logo
      has one row in logo table with a unique logo_id
    • Each logo table row
      is linked to one logo_category row
    • Each time a logo is associated
      with a post, a row is created in post_logos table. It has
      two foreign-key columns: post_id and logo_id.

    In ruby, each Post object could have an array or list of logo objects. Each Logo object composes one Logo_Category object (has one Logo_Category member or variable) .

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

Sidebar

Related Questions

I have two models, Article and Post that both inherit from a base model
I have models of my tables and would like to do a join using
I have models: Post and User(Devise). I am testing controller Post. describe If user
(sorry for any bad English) Let's suppose I have models A, B, C. Each
I have models User and Message. Every user can send messages to other users.
I have models corresponding to database tables. For example, the House class has color,
I have models and their admin code at below. The question is how can
I have models (simplified example): class Group(models.Model): name = models.CharField(max_length = 32) class Person(models.Model):
I have models like this: class IdfPracownicy(models.Model): nazwa = models.CharField(max_length=100) class IdfPracaOpinie(models.Model): nazwa =
I have that situation: I have models Item, Region and Country. class Item(models.Model): name

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.