Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Model Code for Track (post)
class Track < ActiveRecord::Base
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
#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']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment