Skip to content
This repository was archived by the owner on Jul 24, 2020. It is now read-only.
This repository was archived by the owner on Jul 24, 2020. It is now read-only.

Incorporate Cart's relations into ActiveRecord logic #414

Closed
@shippy

Description

@shippy

This is a thought, not a critical issue.

Currently, Cart exists outside of the logical ActiveRecord relations (has_many :cart_reservations, belongs_to :user) because it is never stored in a database. Consequently, the application logic is confusing to work with and maintenance is hard. (It is also possible that the application is to vulnerabilities. For example, no methods that use @cart.items, which is an array of CartReservation.id fields, ever check if @cart.reserver == CartReservation.reserver before applying changes to all @cart.items.)

This RailsCast episode and this StackOverflow topic suggest a way to take advantage of ActiveRecord without the database connection.

Alternatively, the Cart logic could be preserved but be included in User model, with appropriate has_many :cart_reservations designation. This would work, as we anticipate 1-to-1 relation between User and Cart anyway.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions