Hey Paul,
Sorry to keep you waiting on this. Both of the challenges you've come across stem from the fact that the has_many/belongs_to relationship in Cequel is a bit different than it is in ActiveRecord. In particularly, it encodes a parent-child relationship, rather than an arbitrary one-to-many relationship as in ActiveRecord.
For that reason, any Cart that's created needs to know what its parent (User) is; the user_id is actually part of the Cart's primary key (this is automatically handled by the belongs_to declaration in Cequel). Since the User doesn't have any parent, you can create a User first, and then create the user's carts. But you can't create a Cart without a User.
As for the second question, because belongs_to is a parent-child relationship, you can only have one belongs_to in a model class; it can only have one parent. You can have as many has_many declarations as you'd like, though.
So, here's how I'd structure your classes, off the top of my head:
def cart_items
@cart_items ||= CartItem.where(product_id: id)
end
end
Note that the association between CartItems and Products is hand-rolled—Cequel does not currently have a mechanism for describing relationships between models that are not encoded in the primary key. I have thought it would be helpful to provide a references_one/referenced_by functionality to Cequel, although I have not seen a tremendous amount of demand for it, so I haven't made it a priority.
Let me know if that helps and if anything needs clarification!
Mat