Last active
December 24, 2015 10:09
-
-
Save EminenceHC/6782226 to your computer and use it in GitHub Desktop.
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 DrugAssessmentsController < ApplicationController | |
before_filter :authenticate_user! | |
def create | |
@form = DrugAssessment.create(drug_assessment_params) | |
redirect_to drug_assessments_path | |
end | |
def new | |
@year = Date.today.cwyear | |
@week = Date.today.cweek | |
@date = Date.commercial(@year, @week) | |
@string = @date.strftime("%Y/%m/%d") | |
@form = DrugAssessment.new(week: @string, cweek: @week) | |
@user = current_user | |
if | |
@user.loginable_type == 'Student' | |
@loginable = @user.loginable | |
@studentid = @loginable.id | |
@form.student_id = @studentid | |
elsif | |
@user.loginable_type == 'Counselor' | |
@form.student_id = 5 | |
else | |
@form.student_id = 8 | |
end | |
end | |
def index | |
@user = current_user | |
@loginable = @user.loginable | |
if | |
@user.loginable_type == 'Student' | |
@studentid = @loginable.id | |
@l = DrugAssessment.order('cweek DESC').where(student_id: @studentid).search(params[:l]) | |
@form = @l.result | |
elsif | |
@user.loginable_type == 'Counselor' | |
@l = DrugAssessment.search(params[:l]) | |
@form = @l.result | |
else | |
@l = DrugAssessment.search(params[:l]) | |
@form = @l.result | |
end | |
end | |
def update | |
end | |
def show | |
@student = DrugAssessment.find(params[:id]) | |
end | |
end | |
private | |
def drug_assessment_params | |
params.require(:drug_assessment).permit(:id, :student_id, :alcohol, :marijuana, :drug_assessment, :week, :cweek) | |
end | |
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
<div class="span12" style="width:100%;margin:5px;"> | |
<table class="table table-condensed table-bordered table-striped "> | |
<thead> | |
<tr> | |
<th><%= sort_link @l, :student_id, "SID" %></th> | |
<th><%= sort_link @l, :id, "AID" %></th> | |
<th><%= sort_link @l, :created_at, "Date Created" %></th> | |
<th><%= sort_link @l, :did_you_use, "Use" %></th> | |
<th><%= sort_link @l, :alcohol, "Alcohol" %></th> | |
<th><%= sort_link @l, :marijuana, "Marijuana" %></th> | |
<th><%= sort_link @l, :over_the_counter, "Counter" %></th> | |
<th><%= sort_link @l, :inhalent, "Inhalent" %></th> | |
<th><%= sort_link @l, :ecstacy, "Ecstacy" %></th> | |
<th><%= sort_link @l, :crack_cocaine, "Crack/Cocaine" %></th> | |
<th><%= sort_link @l, :heroin, "Heroin" %></th> | |
<th><%= sort_link @l, :methanphetamine, "Meth" %></th> | |
<th><%= sort_link @l, :pcp_lsd_hallucinogen, "Hallucinogen" %></th> | |
<th><%= sort_link @l, :prescription, "Prescription" %></th> | |
<th><%= sort_link @l, :methadone, "Methadone" %></th> | |
<th><%= sort_link @l, :cweek, "Week" %></th> | |
</tr> | |
</thead> | |
<% @form.each do |q| %> | |
<tbody> | |
<tr> | |
<td><%= q.student_id %></td> | |
<td><%= q.id %></td> | |
<td><%= q.created_at %></td> | |
<td><%= q.did_you_use %></td> | |
<td><%= q.alcohol %></td> | |
<td><%= q.marijuana %></td> | |
<td><%= q.over_the_counter %></td> | |
<td><%= q.inhalent %></td> | |
<td><%= q.ecstacy %></td> | |
<td><%= q.crack_cocaine %></td> | |
<td><%= q.heroin %></td> | |
<td><%= q.methanphetamine %></td> | |
<td><%= q.pcp_lsd_hallucinogen %></td> | |
<td><%= q.prescription %></td> | |
<td><%= q.methadone %></td> | |
<td><%= q.cweek %></td> | |
</tr> | |
</tbody> | |
<% end %> | |
</table> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment