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 / service.rb
Last active July 4, 2022 12:08
Roo gem Excel file import - Remove unwanted columns
class EpitomaxService < ActiveRecord::Base
def self.import(file)
allowed_attributes = ["charge_amount","activity_date","last_name","first_name","case_no","program","description","activity_description","description2","created_at","updated_at"]
spreadsheet = open_spreadsheet(file)
spreadsheet.row(1)[0] = 'charge_amount'
spreadsheet.row(1)[1] = 'activity_date'
spreadsheet.row(1)[2] = 'duration'
spreadsheet.row(1)[3] = 'last_name'
@EminenceHC
EminenceHC / gist.xml
Last active January 4, 2016 18:09
XML to JSON post to students path
<message_list>
<message>
<message_id>2629</message_id>
<message_body>
<patient>
<case_no>14958</case_no>
<last_name>Marti</last_name>
<first_name>Pam</first_name>
<middle_name>P</middle_name>
<social_security_no>000000000</social_security_no>
@EminenceHC
EminenceHC / edit.html.erb
Last active January 3, 2016 12:19
Redirect to wrong controller.
<%= simple_form_for @student, :html => { :class => 'form-horizontal' } do |f| %>
<%= f.error_notification %>
<%= f.input :case_no, as: :hidden %>
<%= simple_fields_for @user do |u| %>
<h4>Change website and email passwords for <%= @user.full_name %></h4>
<%= u.error_notification %>
<div class="well">
<%= u.input :password, label: 'New Password' %>
<%= u.input :password_confirmation %>
<%#= u.hidden_field :cp, value: 'true' %>
@EminenceHC
EminenceHC / console_routes.rb
Created January 16, 2014 18:54
Custom update method routing problem.
edit_password_for_student_student GET /students/:id/edit_password_for_student(.:format) students#edit_password_for_student
PATCH /students/:id/edit_password_for_student(.:format) students#update_student_password
PUT /students/:id/edit_password_for_student(.:format) students#update_student_password
POST /students/:id/edit_password_for_student(.:format) students#update_student_password
@EminenceHC
EminenceHC / edit.html.erb
Created January 16, 2014 00:27
Same update method, different validation redirects
<%= simple_form_for @student, :html => { :class => 'form-horizontal' } do |f| %>
<%= f.error_notification %>
<h4>Student Fields:</h4>
<%= f.input :case_no %>
<%= f.input :program %>
<%= f.input :admission_status %>
<%= f.input :temporary_password %>
<%= f.input :admission_date, as: :date_picker %>
@EminenceHC
EminenceHC / change_password.erb
Last active January 3, 2016 03:59
Custom devise method
<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class => 'form-vertical' }) do |f| %>
<%= devise_error_messages! %>
<%= f.input :password, :autocomplete => "off", label: 'New password' %>
<%= f.input :password_confirmation, label: 'Type your new password again' %>
<%= f.input :sign_in_count, :as => :hidden, :input_html => { :value => "2" } %>
<%= f.submit "Update", :class => "btn btn-primary" %>
<% end %>
@EminenceHC
EminenceHC / application_controller.rb
Created January 10, 2014 18:16
Redirect Problem
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
before_filter do
resource = controller_name.singularize.to_sym
method = "#{resource}_params"
params[resource] &&= send(method) if respond_to?(method, true)
end
@EminenceHC
EminenceHC / notify_batch.rb
Last active January 2, 2016 10:48
Conditional Hash Key
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 / controller.rb
Created January 2, 2014 21:59
Selected value instead of prompt.
@quiz_user_name = ResultSet.all.map { |u| [u.user.full_name, u.user_id]}.uniq
@EminenceHC
EminenceHC / _simple_fields_for_user.html.erb
Created December 20, 2013 17:24
Model validation not redirecting to errors.
<%= simple_fields_for @user do |u| %>
<%= u.error_notification %>
<h4>User Fields:</h4>
<%= u.input :first_name %>
<%= u.input :middle_name %>
<%= u.input :last_name %>
<%= u.input :email %>
<%= u.input :social_security_no %>
<%= u.input :sex %>
<%= u.input :date_of_birth, as: :date_picker, input_html: { id: 'dp1', } %>