Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two level inheritance, Child Class don't inherit Middle Class attributes #68

Open
gustavobap opened this issue Feb 21, 2013 · 1 comment

Comments

@gustavobap
Copy link

I'm trying to implement a structure like: GrandFather <- Father <- Son

class GrandFather < ActiveRecord::Base
    acts_as_citier
    attr_accessible :grand_father_attr
end

class Father < GrandFather
    acts_as_citier
    attr_accessible :father_attr
end

class Son < Father

end

class CreateGrandFathers < ActiveRecord::Migration
    def change
        create_table :grand_fathers do |t|
            #citier column
            t.string :type
            t.string :grand_father_attr
            t.timestamps
        end
    end
end

class CreateFathers < ActiveRecord::Migration
    def up
        create_table :fathers do |t|
            t.string :father_attr
        end
        create_citier_view(Father)
    end

    def down
        drop_citier_view(Father)
        drop_table :fathers
    end
end

But if I open rails console and type
> Son.new
The attributes from Father class are missing:

1.9.3-p362 :001 > Son.new
citier -> Root Class
citier -> table_name -> grand_fathers
citier -> Non Root Class
citier -> table_name -> fathers
citier -> tablename (view) -> view_fathers
   (1.1ms)   SELECT COUNT(*)
 FROM pg_tables
 WHERE tablename = 'grand_fathers'


   (0.5ms)   SELECT COUNT(*)
 FROM pg_views
 WHERE viewname = 'grand_fathers'

 => #<Son id: nil, type: "Son", grand_father_attr: nil, created_at: nil, updated_at: nil> 
@gustavobap
Copy link
Author

As a workaround this makes it work for me:

class Son < Father
    acts_as_citier :table_name=>'fathers'
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant