|
|
|
|
|
by culi
228 days ago
|
|
So the underlying assumption is that there is always at least one attribute that serves as a "discriminator" between the billing plans, right? Is it possible to represent something like this then? ```rb [:red, 1.month, 10]
[:red, 1.year, 120]
[:blue, 1.month, 120]
[:blue, 1.year, 300]
```Every possible attribute (name, interval, amount) has at least two objects that share a value |
|
If you want to make it even shorter, you have a few options - it really just comes down to preference:
> there is always at least one attribute that serves as a "discriminator" between the billing plans, rightJust a note: if you try to create two plans with the same attributes, that would error because of ActiveRecord uniqueness validations (and DB constraints). No point in having multiple identical plans.