active_record-acts_as | Simulate multi-table inheritance | Application Framework library
kandi X-RAY | active_record-acts_as Summary
kandi X-RAY | active_record-acts_as Summary
Simulate multi-table inheritance for activerecord models
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of active_record-acts_as
active_record-acts_as Key Features
active_record-acts_as Examples and Code Snippets
Community Discussions
Trending Discussions on active_record-acts_as
QUESTION
I'm creating a Rails 5.2 e-commerce application. I am using the active_record-acts_as gem to simulate multi-table inheritance that has a parent class named Product
and multiple subclasses (Book
, Clothing
, Electronic
...etc) that all act as a Product
(they inherit all of Product's attributes and methods).
Each Product can only be created in the context of a Category
, which corresponds to the names of Product's subclasses. For a visual, here is my current ProductsController...
ANSWER
Answered 2018-Jul-26 at 18:42I was able to correct the issue of updating timestamps twice by adding touch: false
to the acts as association in Product's subclasses...
QUESTION
I have a complicated relationship where I have multiple models require addresses. This usually means using a polymorphic relationship like so:
...ANSWER
Answered 2017-Mar-28 at 12:39What separates the address categories? You mention that you may have a billing address and a site address.
If for example the categories are determined by an attribute called 'category', then all you have to do is set a condition on the association declarations on the addressable:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install active_record-acts_as
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page