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 / drug_assessments_controller.rb
Last active December 23, 2015 22:09
Ransack and Simple_Form
class DrugAssessmentsController < ApplicationController
before_filter :authenticate_user!
def create
@form = DrugAssessment.create(drug_assessment_params)
redirect_to drug_assessments_path
end
def new
class DrugAssessmentsController < ApplicationController
before_filter :authenticate_user!
def create
@form = DrugAssessment.create(drug_assessment_params)
redirect_to drug_assessments_path
end
def new
@EminenceHC
EminenceHC / Console Log (Database Query)
Last active December 24, 2015 14:48
Polymorphic Update Problem - User has one student
Started PATCH "/students/3" for 127.0.0.1 at 2013-10-03 13:10:37 -0700
Processing by StudentsController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"F/EvSPLZeYtB7lNNsCs8eA/bB3LMjcP+OvKfzBFoFLo=", "student"=>{"case_no"=>"7777", "program"=>"Web Development", "admission_status"=>"", "temporary_password"=>"[FILTERED]", "admission_date(1i)"=>"2013", "admission_date(2i)"=>"10", "admission_date(3i)"=>"3", "admission_date(4i)"=>"15", "admission_date(5i)"=>"27", "user"=>{"name"=>"Travis Glover", "first_name"=>"Trav", "middle_name"=>"L", "last_name"=>"Glover", "email"=>"glovertravis@gmail.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "social_security_no"=>"654544303", "sex"=>"M", "date_of_birth(1i)"=>"2013", "date_of_birth(2i)"=>"3", "date_of_birth(3i)"=>"13", "street_address"=>"473 W Shaw Ave", "city"=>"Fresno", "state"=>"CA", "postal_code"=>"93704", "home_phone"=>"3333333333", "work_phone"=>"5556667777", "mobile_phone"=>"5557778888", "message_id"=>""}}, "commit"=>"Update
@EminenceHC
EminenceHC / ERROR
Last active December 25, 2015 00:29
ActiveRecord::EagerLoadPolymorphicError at /students
Can not eagerly load the polymorphic association :loginable
<% @table.each do |s| %>
@EminenceHC
EminenceHC / drug_assessments_controller.rb
Created October 17, 2013 21:35
Refactoring Controller
class DrugAssessmentsController < ApplicationController
before_filter :authenticate_user!
def create
@form = DrugAssessment.create(drug_assessment_params)
@query_string = drug_assessment_params[:student_id]
<% title "Take Survey" %>
<%= form_for @survey, :url => { :action => "clone"}, method: :post do |f| %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
<%= f.hidden_field :student_id %>
</p>
<%= f.fields_for :questions do |builder| %>
@EminenceHC
EminenceHC / index.html.erb
Created October 31, 2013 22:51
Serialization
<h3>Result Sets</h3>
<div class="span12" style="width:100%;margin:5px;">
<%= simple_form_for @result_set, url: {action: 'create'} do |f| %>
<% @surveys.each do |a| %>
<ul>
<%= a.name %>
<%= a.id %>
<br><br>
@EminenceHC
EminenceHC / index.html.erb
Created November 5, 2013 18:43
Comparing Arrays
<h3>Result Sets</h3>
<div class="span12" style="width:100%;margin:5px;">
<% if current.loginable_type != 'Student' %>
<%= simple_form_for(result_sets_path, :method =>'get', :html => { :class => 'form-horizontal' }) do %>
<%= select_tag 'id', options_for_select(@quiz_id), { :prompt => 'Quiz Name'} %>
<%= select_tag 'student_id', options_for_select(@quiz_student_name), { :prompt => 'Student Name'} %>
<%= submit_tag 'Submit', :class => 'btn btn-primary' %>
<% end %>
<% end %>
@EminenceHC
EminenceHC / result_set.rb
Last active December 27, 2015 14:39
Serialized Hash in Strong Parameters
class ResultSet < ActiveRecord::Base
belongs_to :survey
belongs_to :student
accepts_nested_attributes_for :survey
attr_accessor :score, :correct_count, :total_count, :percent
serialize :serial
end
@EminenceHC
EminenceHC / index.html.erb
Created November 7, 2013 23:00
Sum or Average of Table Column
<h3>Result Sets</h3>
<div class="span12" style="width:100%;margin:5px;">
<% if current.loginable_type != 'Student' %>
<%= simple_form_for(result_sets_path, :method =>'get', :html => { :class => 'form-horizontal' }) do %>
<%= select_tag 'id', options_for_select(@quiz_id), { :prompt => 'Quiz Name'} %>
<%= select_tag 'student_id', options_for_select(@quiz_student_name), { :prompt => 'Student Name'} %>
<%= submit_tag 'Submit', :class => 'btn btn-primary' %>
<% end %>
<% else %>