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 ResultController < ApplicationController | |
def index | |
@question = Question.find(params[:q]) | |
@answer = Answer.find_by(questionid: @question.id) | |
end | |
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
class ResultController < ApplicationController | |
def index | |
if params[:a].present? | |
create | |
else | |
@question = Question.find(params[:q]) | |
@answers = Answer.where(question_id: @question.id) | |
end | |
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
def addToDB | |
@questions = [{:question=>"Huvudvärk"}, {:question=>"Nervositet eller skälvningar inombords"}] | |
@questions.each do |p| | |
Question.create(question: p['question']) | |
end | |
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
def addToDB | |
@questions = ['Huvudvärk', 'Nervositet eller skälvningar inombords'] | |
@questions.each do |q| | |
Question.create(question: q) | |
end | |
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
def checkpatient | |
patient = Patients.find_by(handle: params[:name]) | |
if patient && login? | |
session[:patient_id] = patient.id | |
redirect_to result_index_path(:q => 1) | |
else | |
redirect_to patients_path, notice: "Namnet finns inte registrerat" | |
end | |
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
class ApplicationController < ActionController::Base | |
# Prevent CSRF attacks by raising an exception. | |
# For APIs, you may want to use :null_session instead. | |
protect_from_forgery with: :exception | |
protected | |
def authorize | |
#Patients.exists?(handle: params[:name], login?) | |
unless Patients.find_by(handle: params[:name]) |
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
In my controller: | |
@questionsDone = Results.questionsDone() | |
In my helper: | |
def questionsDone() | |
questionsDone = count(:question_id, :group => :user_id) | |
return questionsDone | |
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
I min controller... resultsController.rb: | |
@patientName = getPatientName(params[:id]) | |
I min model results.rb: | |
def self.getPatientName(id) | |
Patients.find_by_id(id).handle | |
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
func doConvert(inValues: Array<String>) -> String { | |
var convertValue: Double | |
var convertFromUnit: String | |
var convertToUnit: String | |
var goalValue = 0.0 | |
var startChar: String = inValues[0].substringToIndex(1) | |
println(startChar) |
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
rake db:drop db:create db:migrate db:seed --trace | |
** Invoke db:drop (first_time) | |
** Invoke db:load_config (first_time) | |
** Execute db:load_config | |
** Execute db:drop | |
** Invoke db:create (first_time) | |
** Invoke db:load_config | |
** Execute db:create | |
** Invoke db:migrate (first_time) | |
** Invoke environment (first_time) |
OlderNewer