Skip to content

Instantly share code, notes, and snippets.

@faust45
Created April 6, 2010 08:28
Show Gist options
  • Save faust45/357359 to your computer and use it in GitHub Desktop.
Save faust45/357359 to your computer and use it in GitHub Desktop.
class BaseModel < CouchRest::ExtendedDocument
include CouchRest::Validation
extend ActiveModel::Naming
include ActiveModel::Conversion
include Dirty
include Uniq
use_database DB
class <<self
def delete_all
all.each do |doc|
doc.destroy
end
end
end
#need false for form_for helper
def persisted?
false
end
end
class Content < BaseModel
unique_id :slug
property :title
property :author
property :co_authors, :default => []
property :description
property :tags, :default => []
property :categories, :default => []
property :slug, :read_only => true
timestamps!
view_by :title
before_save do
if new?
self[:slug] = Russian::translit(self.title)
end
end
class <<self
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment