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 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
  • 3 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 in /app/models: class Area < ActiveRecord::Base has_many :locations end class
I have the following models: class Person < ActiveRecord::Base has_many :accounts, :through => :account_holders
I have a rails 3.1 app with the following Models: class Post < ActiveRecord::Base
I have the following: app/models/order.rb class Order < ActiveRecord::Base belongs_to :client accepts_nested_attributes_for :client end
I have the following model in my /app/models folder: class MyModel < ActiveRecord::Base require
I have the following models in my Django app. How can I from the
I have the following domain classes in my app class Video { private Image
I have the following models in my app (only showing the related scopes): class
in a django-tastypie app I have the following Django-models: class Car(models.Model): name=models.CharField('name',max_length=64) class CarTrack(models.Model):

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.