Hi all,
I’m starting a RoR3 project with Cassandra Database using Cequel 1.4.1,
a Ruby ORM for Cassandra. It’s a great ORM and easy to use because of
it’s ActiveRecord-like coding and model association style. But as i go
on with my development using model associations i encountered some
errors and searched for answers, and so i have read the post here about
Cequel by one of the author that’s why i’m hoping that i can get help
here with my problem.
My problems encountered with the given model association are:
class User
include Cequel::Record
has_many :carts
has_many :cart_items
key :id, :uuid, auto: true
column :email, :text
column :encrypted_password, :text
timestamps
end
class Cart
include Cequel::Record
belongs_to :user
has_many :cart_items
key :id, :uuid, auto: true
column :name, :text
timestamps
end
class Product
include Cequel::Record
has_many :cart_items
key :id, :uuid, auto: true
column :name, :text
timestamps
end
class CartItems
include Cequel::Record
belongs_to :user
belongs_to :cart
belongs_to :product
end
-
For User and Cart model, the association between both the model is
required upon creation of the data. I want to create either the User or
the Cart first and set the connection for the both at a later time. I
also tried putting this code in Cart model but still doesn’t work:
validates :user_id, presence: false -
For CartItems model, running rake cequel:migrate outputs an error
saying Cequel::Record::InvalidRecordConfiguration: Can’t declare more
than one belongs_to association.
I hope someone can help me on this, or can give me a better solution or
idea on what i’m trying to achieve here using Cassandra database.
Thanks!