Cequel is a full-featured Cassandra ORM for Ruby.
source 'https://rubygems.org'
gem 'rails'
gem 'cequel'
class User
include Cequel::Record
key :id, :uuid, auto: true
column :email, :ascii
column :encrypted_password, :ascii
validates :email, :encrypted_password, presence: true
end
$ rake cequel:migrate
Synchronized schema for User
$
class User
include Cequel::Record
key :id, :uuid, auto: true
column :email, :ascii
column :encrypted_password, :ascii
has_many :messages
validates :email, :encrypted_password, presence: true
end
class Message
belongs_to :user
key :id, :timeuuid, auto: true, order: :desc
column :sender_id, :uuid
column :body, :text
end
class MessagesController < ApplicationController
def index
@messages = current_user.messages.from(1.week.ago).limit(10)
end
def create
User.find(params[:id]).messages.create!(
sender_id: current_user.id,
body: params[:body]
)
end
end