Skip to content

Instantly share code, notes, and snippets.

@EminenceHC
Created November 25, 2013 16:44
Show Gist options
  • Save EminenceHC/7644355 to your computer and use it in GitHub Desktop.
Save EminenceHC/7644355 to your computer and use it in GitHub Desktop.
module DrugAssessmentMethods
@users = User.all
@users_array = User.where(loginable_type: 'Student').includes(:loginable).all.map { |u| [u.full_name, u.loginable.id] }
if current_user.loginable_type == 'Student'
@sid = current_user.loginable.id
elsif current_user.loginable_type != 'Student'
if
params[:student_id].present?
@sid = params[:student_id]
else
@sid = 0
end
end
@l = DrugAssessment.order('cweek DESC').where(student_id: @sid).search(params[:l])
@form = @l.result
@test = Array.new
@form.each do |r|
unless r.cweek.nil? or r.cweek == 0
@test.push(r.cweek)
end
end
@test = @test.uniq
@year = Date.today.cwyear
@current_cweek = Date.today.cweek
@start_cweek = 34
@emptycount = 0
while @current_cweek > @start_cweek do
if @test.include?(@current_cweek)
else
charles = DrugAssessment.new(cweek: @current_cweek)
@form << charles
@emptycount = @emptycount + 1
end
@current_cweek = @current_cweek - 1
end
@form = @form.sort_by{|a| -(a.cweek)}
end
def index
# pulled from module at: lib/drug_assessment_methods.rb
include DrugAssessmentMethods
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment