这是indexloc提供的服务,不要输入任何密码
Skip to content

Cannot access child attributes from Parent class actable #60

@asad-accemy

Description

@asad-accemy
class Product < ActiveRecord::Base
    actable as: :as_product
end

class Car < ActiveRecord::Base
    acts_as :product, as: :as_product
end

class Truck < ActiveRecord::Base
    acts_as :product, as: :as_product
end

#Table definition

Product
t.id
t.as_product_id
t.as_product_type

Car
t.id
t.vin

Gemfile

gem 'active_record-acts_as'

ruby 3.2.2
Rails 6.1.7.10

Issue is that below command return NoMethodError while earlier while I was using acts_as_relation same syntax use to work and fetch Vin from Car model

p = Product.last
p.vin #Now it throws error saying undefined method `vin' for #<Product>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions