I am working on the scenario which is different and I have model structures like
This is my main model which has STI and working fine.
class Post < ActiveRecord::Base
# table is "posts" as per default behaviour
# have column "type"
end
This is my another model is FakePost (looks weird but required :( ). This is totally clone structure of Post model. These objects will be become Post object as per requirement.
My problem is to keep type column in FakePost but should not use STI.
What I tried is below solution as per Rails -- use type column without STI?
class FakePost < Post
self.table_name = 'fake_posts'
private
def self.inheritance_column
nil
end
end
Above solution doesn't work. Because it is running the below querie
irb(main):001:0> FakePost.first
FakePost Load (1.0ms) SELECT "fake_posts".* FROM "fake_posts" WHERE "fake_posts"."type" IN ('FakePost') ORDER BY "fake_posts"."id" ASC LIMIT 1
=> nil
What I want is that type based queries shouldn't run.
Is there any solution what I can do.
Because I can rename the column but when I convert FakePost object to Post object then I can't directly use dup.
Please let me know if I am not much clear and need more information.