Created
April 6, 2010 08:28
-
-
Save faust45/357359 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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