Created
June 26, 2012 08:07
-
-
Save kibaekr/2994293 to your computer and use it in GitHub Desktop.
Model Code for Track (post)
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 Track < ActiveRecord::Base | |
acts_as_taggable | |
include PgSearch | |
pg_search_scope :search_by_title, :against => :title #:using => [:tsearch => {:prefix => true}], #:trigram, :dmetaphone] | |
pg_search_scope :search_by_weight, | |
:against => { | |
:title => 'B', | |
:description => 'C' | |
}, | |
:associated_against => { | |
:tags => [:name] | |
}, | |
:using => [:tsearch] #, :trigram, :dmetaphone] | |
belongs_to :author, :class_name => "User", :foreign_key => "author_id" | |
has_many :track_users | |
has_many :users, :through => :track_users | |
# attr_accessible :title, :category, :difficulty, :description, :missions_attributes, :author_id | |
has_many :missions, :order => "position ASC", :dependent => :destroy | |
accepts_nested_attributes_for :missions, :allow_destroy => true | |
has_many :track_comments, :dependent => :destroy | |
mount_uploader :image, TrackImageUploader | |
acts_as_voteable | |
#validates :author_id, :presence => true | |
#validates :title, :presence => true | |
#validates :description, :presence => true | |
#validates :difficulty, :presence => true | |
#validates :intendedtime, :presence => true | |
DIFFICULTIES = ['Beginner', 'Medium', 'Advanced'] | |
CATEGORIES = ['Technology and Internet', 'Creative Arts and Music', 'Academics and Test Prep', 'Business and Professional', 'Sports and Health', 'Language', 'Game', 'Lifestyle', 'Other'] | |
SORT = ['Top','Recent'] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment