Skip to content

Instantly share code, notes, and snippets.

View EminenceHC's full-sized avatar

EminenceHC EminenceHC

  • Eminence Healthcare
  • Fresno CA
View GitHub Profile
@EminenceHC
EminenceHC / students_controller.rb
Last active August 29, 2015 13:55
Conditional .where on Social Security No
runquery = Student.joins(:user)
runquery = runquery.where(users: {first_name: params[:first_name]}) if params[:first_name].present?
runquery = runquery.where(users: {last_name: params[:last_name]}) if params[:last_name].present?
runquery = runquery.where(users: {loginable_id: params[:id]}) if params[:id].present?
runquery = runquery.where(program: params[:program]) if params[:program].present?
runquery = runquery.where(users: {social_security_no: '000000000'}) if params[:social_security_no] == 'no_social' # '000000000' || '' || '0'
runquery = runquery.select('students.*, students.id as sid, users.*')
@query = runquery
require 'daemons'
Daemons.run('notify_batch.rb')
Processing by StudentsController#index as HTML
DEPRECATION WARNING: Relation#all is deprecated. If you want to eager-load a relation, you can call #load (e.g. `Post.where(published: true).load`). If you want to get an array of records from a relation, you can call #to_a (e.g. `Post.where(published: true).to_a`). (called from index at /Users/travis.glover/RubymineProjects/eminence/app/controllers/students_controller.rb:82)
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."loginable_type" = 'Student'
Student Load (0.2ms) SELECT "students".* FROM "students" WHERE "students"."id" IN (1, 3, 51, 71, 74, 75, 76, 77, 78, 79, 80)
DEPRECATION WARNING: Relation#all is deprecated. If you want to eager-load a relation, you can call #load (e.g. `Post.where(published: true).load`). If you want to get an array of records from a relation, you can call #to_a (e.g. `Post.where(published: true).to_a`). (called from index at /Users/travis.glover/RubymineProjects/eminence/app/controllers/students_controller.rb:8
before_filter :fetch_user, only: :update
before_filter :activate, only: :update
def update
@student.update(student_params)
@user.update(user_params)
if @student.update(student_params) && @user.update(user_params)
redirect_to students_path, notice: "Student has been updated."
@EminenceHC
EminenceHC / import.rb
Last active August 29, 2015 13:56
Trying to .strpptime on a null value
require 'rb-inotify'
require 'json'
require 'rest_client'
require 'crack'
require 'active_support/all'
#0 Notifier Start
notified = INotify::Notifier.new
#1 File is placed within the folder (by Epitomax)
@EminenceHC
EminenceHC / query.rb
Last active August 29, 2015 13:56
How to order this query?
con = Student.joins(:user)
con = con.where("discharge_date < admission_date OR discharge_date IS NULL")
con = con.where(users: {loginable_type: 'Student'}).all.map { |u| [u.user.full_name, u.id] }.uniq
@users_array_id = con
ArgumentError at /drug_assessments
Direction should be :asc or :desc
@EminenceHC
EminenceHC / counselors_controller.rb
Last active August 29, 2015 13:56
Create a user relationship on counselor update.
class CounselorsController < ApplicationController
before_filter :authenticate_user!
before_filter :find_counselor_by_id, only: [:show, :edit, :update, :destroy, :toggle_active_on, :toggle_active_off]
load_and_authorize_resource
def create
end
<div>
<div class ='well' style="float:left;">
<% if can? :manage , :all %>
<%= simple_form_for(students_path, method: 'get', html: { class: 'form-horizontal', style: 'margin-bottom:-5px;', autocomplete: 'on' }) do %>
<br><br>
<%= @current %>
<br><br>
<%= select_tag 'active', options_for_select('True'=>'true', 'False'=>'false'), { prompt: 'Active', style: 'margin:5px 0px 5px 0px;'} %>
<%= submit_tag 'Submit', :class => 'btn btn-primary', style: 'margin:5px 0px 5px 0px;' %>
@EminenceHC
EminenceHC / survey.rb
Created February 19, 2014 22:28
Has many through one way connection problem.
class Survey < ActiveRecord::Base
has_many :survey_users
has_many :users, through: :survey_users
end