Skip to content

Instantly share code, notes, and snippets.

@jacqui
Created December 3, 2009 20:32
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 jacqui/248488 to your computer and use it in GitHub Desktop.
Save jacqui/248488 to your computer and use it in GitHub Desktop.
class Form
include MongoMapper::Document
key :name, String, :required => true
key :headline, String, :required => true
key :subject_filter, String
key :submission_email, String
key :slug, String
key :thanks, String
key :notification_emails, Array
key :section, String
key :intro, String
key :header, String
key :nyt_wrapper, Boolean, :default => true
key :image_upload, Boolean, :default => true
key :project_id, Mongo::ObjectID
key :status, String, :default => 'active'
key :keywords, String
key :image_count, Integer, :default => 0
key :text_count, Integer, :default => 0
key :submission_count, Integer, :default => 0
timestamps!
belongs_to :project
many :submissions
many :fields
before_save :update_counts
def self.per_page
100
end
def self.find_all_not_equal(column, value)
find(:all, :conditions => { column => { '$ne' => value } })
end
def update_counts
self[:submission_count] = total_submissions
self[:image_count] = total_images
self[:text_count] = total_texts
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment