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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:59:59+00:00 2026-06-12T03:59:59+00:00

I have some namespaced models which I’m trying to override the default rails table

  • 0

I have some namespaced models which I’m trying to override the default rails table name for them because I’m connecting to an existing legacy database.

My models are:

/app/models/licenses.rb

  module Licenses
    def self.table_name_prefix
      ''
    end
  end

/app/models/licenses/employee.rb

class Licenses::Employee < ActiveRecord::Base
  establish_connection YAML::load(File.open("#{Rails.root}/config/licenses_database.yml"))[Rails.env]
  self.table_name = 'EMPLOYEE'
  self.primary_key = 'EMPLOYEE_ID'
end

/app/models/licenses/inspection.rb

class Licenses::Inspection < ActiveRecord::Base
  establish_connection YAML::load(File.open("#{Rails.root}/config/licenses_database.yml"))[Rails.env]
  self.table_name = 'INSPECTION'
  self.primary_key = 'INSPECTION_ID'
end

When I run my tests, errors are generated as the

PG::Error: ERROR: relation “licenses_employees” does not
exist

Is there something I’m missing to remove the prefix from the namespaced models?

UPDATE: I’ve tried setting the table name prefix in the Licenses module to ‘testing_’ instead of ” and I still get the same error message.

  • 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-12T04:00:00+00:00Added an answer on June 12, 2026 at 4:00 am

    It appears that the issue at hand was that I used the rails generator to create the namespace models for the existing database. The generator had created the fixture files as namespaced fixtures i.e. /test/fixtures/licenses/employees.yml. When I tried to run my tests, Rails would try to insert the fixtures into the tables based on the fixture name/path. I just needed to move the fixture files for the existing database and rename them to match the table name that I set in the models i.e. /test/fixtures/licenses/employee.yml.

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

Sidebar

Related Questions

I have some django apps which are versioned by app name. appv1 appv2 The
I have some sets of xml in which I have to add namespace prefix
I have some tables roughly like so: Client: id name Employee id name Email
I have an ASP.NET MVC App, which use EF code First, for some reason
I have a class reflecting my dbml file which extends DataContext, but for some
I have the following class. Note there are some key values which are not
I am having some trouble I have $currentPages variable which store below data Array
I have some extern 'd variables in a namespace in a header file, and
If I have some php classes inside a namespace com\test and want to import
I have made a namespaces framework for javascript. I am loading some plugins (.js

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.