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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:06:44+00:00 2026-05-31T18:06:44+00:00

I am currently developing a mountable engine. Within the engine I have the following

  • 0

I am currently developing a mountable engine. Within the engine I have the following two models:

  module Ems
    class Channel < ActiveRecord::Base
      has_and_belongs_to_many :categories
    end
  end

  module Ems
    class Category < ActiveRecord::Base
      has_and_belongs_to_many :channels
    end
  end

These are the db migration files:

  class CreateEmsChannels < ActiveRecord::Migration
    def change
      create_table :ems_channels do |t|
        t.string :slug
        t.string :name

        t.timestamps
      end
    end
  end

  class CreateEmsCategories < ActiveRecord::Migration
    def change
      create_table :ems_categories do |t|
        t.string :slug
        t.string :name
        t.text :strapline

        t.timestamps
      end
    end
  end


  class CreateEmsCategoriesChannels < ActiveRecord::Migration
    def up
      # Create the association table
      create_table :ems_categories_channels, :id => false do |t|
        t.integer :category_id, :null => false
        t.integer :channel_id, :null => false
      end

      # Add table index
      add_index :ems_categories_channels, [:category_id, :channel_id], :unique => true
    end
  end

The problem starts when I try to retrieve the associated objects.
As an example, when I call @channel.get :categories I get the following error:

Mysql2::Error: Table 'ems_development.categories_channels' doesn't exist: 
SELECT `ems_categories`.* 
FROM `ems_categories` 
INNER JOIN `categories_channels` 
ON `ems_categories`.`id` = `categories_channels`.`category_id` 
WHERE `categories_channels`.`channel_id` = 1

As you can see its missing off the isolate_namespace value on the link table, as it should look for the association on the table ems_categories_channels not categories_channels

Anyone had similar problems or am I missing something?

  • 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-31T18:06:45+00:00Added an answer on May 31, 2026 at 6:06 pm

    You can explicitly set the join table name (per the documentation).

      module Ems
        class Channel < ActiveRecord::Base
          has_and_belongs_to_many :categories, :join_table => 'ems_categories_channels'
        end
      end
    
      module Ems
        class Category < ActiveRecord::Base
          has_and_belongs_to_many :channels, :join_table => 'ems_categories_channels'
        end
      end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently developing a PHP framework and have ran into my first problem. I need
I'm currently developing a widget that can be embedded within a page. However, when
Im currently developing an API, and one thing that I decided was to have
I'm currently developing a custom module and for some reason it appends a blank
I'm currently developing a camera app, where I have to set the camera preview
Im currently developing a MVC application Framework and I have come for some advise
im currently developing an app which plays the steam audio using MediaPlayer class. And
I am currently developing an app for iPhone. I have finished most of it,
I'm currently developing a toolbar for chrome and i have some issues with my
Im currently developing an webapplication that are going to have an Autocomplete search form,

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.