personal-selected_course/app/models/student_assignment.rb

19 lines
770 B
Ruby

class StudentAssignment
include Mongoid::Document
include Mongoid::Timestamps
include Slug
field :assignment_content, as: :slug_title, type: String, localize: true, default: ""
has_many :student_assignment_files, :dependent => :destroy, :autosave => true
accepts_nested_attributes_for :student_assignment_files, :allow_destroy => true
belongs_to :course_assignment
belongs_to :member_profile
def display_created_at
self.created_at.strftime("%Y-%m-%d %H:%M")
end
def display_updated_at
self.updated_at.strftime("%Y-%m-%d %H:%M")
end
def display_student_assignment_files
self.student_assignment_files.map{|f| "<a href=\"#{f.file.url}\" title=\"#{f.title}\">#{f.title}</a>"}.join("<br>").html_safe
end
end