public
Created

Model Code for Track (post)

  • Download Gist
Track.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.