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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:14:08+00:00 2026-05-10T21:14:08+00:00

I have the following models. # app/models/domain/domain_object.rb class Domain::DomainObject < ActiveRecord::Base has_many :links_from, :class_name

  • 0

I have the following models.

# app/models/domain/domain_object.rb class Domain::DomainObject < ActiveRecord::Base   has_many :links_from, :class_name => 'Link', :as => :from, :dependent => :destroy end  # app/models/link.rb class Link < ActiveRecord::Base   belongs_to :from, :polymorphic => true    belongs_to :object_value, :polymorphic => true end 

Problem is, when I do the following, the from_type doesn’t prefix the Domain namespace to the model e.g.

 Domain::DomainObject.all(:include=> :links_from ) 

That causes the following SELECT:

 SELECT `links`.* FROM `links` WHERE (`links`.`from_id` IN (5,6,12,13,18,24,25,27,29,30,31,32,34,35,39) and `links`.`from_type` = 'DomainObject') 

The query should be:

 SELECT `links`.* FROM `links` WHERE (`links`.`from_id` IN (5,6,12,13,18,24,25,27,29,30,31,32,34,35,39) and `links`.`from_type` = 'Domain::DomainObject') 

because Rails automatically saves the model with the namespace.

I’ve seen a few recommendations on Rails sites about doing something like this:

   belongs_to :from, :polymorphic => true, :class_name => 'Domain::DomainObject' 

However, that doesn’t appear to work either.

So, is there a better way to do this? Or is this not supported?

  • 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. 2026-05-10T21:14:09+00:00Added an answer on May 10, 2026 at 9:14 pm

    To fix this, I did a include Domain in the DomainObject model and set ActiveRecord::Base.store_full_sti_class = true in config/environment.rb.

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

Sidebar

Related Questions

I have the following code: # app/models/part.rb class Part < ActiveRecord::Base has_many :lots #
I have the following models in my app (only showing the related scopes): class
I have the following models in a Rails 3 app, and select requirement: class
If I have the following models in a Python (+ Django) App Engine app:
I'm trying to understand and figure good practices for designing your app/domain models (POCOs/DTOs).
Using Google App Engine and GQL and Python: in my datastore I have something
I'm just getting into autotest and i have the following problem. How do I
Just looking for some advice on how to structure my relationships in an app
I'm new to testing, so please forgive me for this question In the cakephp
The ASP.NET runtime is meant for short work loads that can be run in

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.