Skip to content

Instantly share code, notes, and snippets.

@outoftime
Created January 14, 2015 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save outoftime/e10ab2112edde79804b1 to your computer and use it in GitHub Desktop.
Save outoftime/e10ab2112edde79804b1 to your computer and use it in GitHub Desktop.
class Post
include Cequel::Record
belongs_to :blog
key :id, :timeuuid, auto: true
column :author_id, :timeuuid
# other column definitions
def author
@author ||= User.find(author_id)
end
def author=(author)
@author = author
self.author_id = author.id
end
end
class User
include Cequel::Record
key :id, :timeuuid, auto: true
column :username, :text
# other column definitions
def posts
@posts ||= Post.where(author_id: id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment