Created
December 3, 2009 20:32
-
-
Save jacqui/248488 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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