Skip to content

Instantly share code, notes, and snippets.

View ratnose's full-sized avatar

ratnose ratnose

  • Sweden
View GitHub Profile
class ResultController < ApplicationController
def index
@question = Question.find(params[:q])
@answer = Answer.find_by(questionid: @question.id)
end
end
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
def addToDB
@questions = [{:question=>"Huvudvärk"}, {:question=>"Nervositet eller skälvningar inombords"}]
@questions.each do |p|
Question.create(question: p['question'])
end
end
def addToDB
@questions = ['Huvudvärk', 'Nervositet eller skälvningar inombords']
@questions.each do |q|
Question.create(question: q)
end
end
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
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])
In my controller:
@questionsDone = Results.questionsDone()
In my helper:
def questionsDone()
questionsDone = count(:question_id, :group => :user_id)
return questionsDone
end
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
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)
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)