Created
May 1, 2011 02:25
-
-
Save JESii/950185 to your computer and use it in GitHub Desktop.
SimpleForm_NoErrors
This file contains hidden or 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
###Model: incident_report.rb | |
# == Schema Information | |
# Schema version: 20110425214240 | |
# | |
# Table name: incident_reports | |
# | |
# id :integer not null, primary key | |
# investigator_name :string(255) | |
# employee_name :string(255) not null | |
# position :string(255) | |
# hire_date :date | |
# incident_date :date not null | |
# incident_time :time | |
# date_first_reported :date | |
# supervisor :string(255) | |
# department :string(255) | |
# witnesses :string(255) | |
# incident_location :string(255) not null | |
# injury :text | |
# incident_description :text not null | |
# injury_causative_factor :text | |
# injury_causative_factor_reason :text | |
# actions_for_correction_prevention :text | |
# responsible_for_correction :string(255) | |
# correction_expected_completion_date :date | |
# correction_actual_completion_date :date | |
# drug_alcohol_test_given :boolean | |
# flags_near_miss :boolean | |
# flags_property_damage :boolean | |
# flags_first_aid :boolean | |
# flags_medical :boolean | |
# flags_lost_time :boolean | |
# employee_following_procedures :boolean | |
# employee_lack_of_training :boolean | |
# employee_not_paying_attention :boolean | |
# employee_acting_per_common_practice :boolean | |
# employee_exceeding_physical_capacity :boolean | |
# employee_using_wrong_equipment :boolean | |
# employee_taking_short_cut :boolean | |
# employee_willful_misconduct :boolean | |
# employee_other :boolean | |
# factor_equipment_failure :boolean | |
# factor_wrong_tools :boolean | |
# factor_poor_procedures :boolean | |
# factor_workplace_conditions :boolean | |
# factor_repetitive_stress :boolean | |
# factor_poor_equipment_guarding :boolean | |
# factor_poor_maintenance :boolean | |
# factor_poor_lighting :boolean | |
# factor_unidentified_uncorrected_workplace_hazards :boolean | |
# factor_unfamiliar_surroundings :boolean | |
# reason_inadequate_rule_enforcement :boolean | |
# reason_lack_of_sufficient_training :boolean | |
# reason_lack_of_hazard_mitigation :boolean | |
# reason_lack_of_supervisor_involvement :boolean | |
# reason_plant_equipment_layout :boolean | |
# reason_lack_of_accountability :boolean | |
# reason_poor_tools_or_maintenance :boolean | |
# reason_lack_of_proper_safety_signs :boolean | |
# created_at :datetime | |
# updated_at :datetime | |
# reason_lack_of_employee_involvement :boolean | |
# | |
class IncidentReport < ActiveRecord::Base | |
validates_presence_of :investigator_name, :employee_name, :incident_date, :injury, :incident_description | |
end | |
###Schema | |
# This file is auto-generated from the current state of the database. Instead | |
# of editing this file, please use the migrations feature of Active Record to | |
# incrementally modify your database, and then regenerate this schema definition. | |
# | |
# Note that this schema.rb definition is the authoritative source for your | |
# database schema. If you need to create the application database on another | |
# system, you should be using db:schema:load, not running all the migrations | |
# from scratch. The latter is a flawed and unsustainable approach (the more migrations | |
# you'll amass, the slower it'll run and the greater likelihood for issues). | |
# | |
# It's strongly recommended to check this file into your version control system. | |
ActiveRecord::Schema.define(:version => 20110425214240) do | |
create_table "incident_reports", :force => true do |t| | |
t.string "investigator_name" | |
t.string "employee_name", :null => false | |
t.string "position" | |
t.date "hire_date" | |
t.date "incident_date", :null => false | |
t.time "incident_time" | |
t.date "date_first_reported" | |
t.string "supervisor" | |
t.string "department" | |
t.string "witnesses" | |
t.string "incident_location", :null => false | |
t.text "injury" | |
t.text "incident_description", :null => false | |
t.text "injury_causative_factor" | |
t.text "injury_causative_factor_reason" | |
t.text "actions_for_correction_prevention" | |
t.string "responsible_for_correction" | |
t.date "correction_expected_completion_date" | |
t.date "correction_actual_completion_date" | |
t.boolean "drug_alcohol_test_given" | |
t.boolean "flags_near_miss" | |
t.boolean "flags_property_damage" | |
t.boolean "flags_first_aid" | |
t.boolean "flags_medical" | |
t.boolean "flags_lost_time" | |
t.boolean "employee_following_procedures" | |
t.boolean "employee_lack_of_training" | |
t.boolean "employee_not_paying_attention" | |
t.boolean "employee_acting_per_common_practice" | |
t.boolean "employee_exceeding_physical_capacity" | |
t.boolean "employee_using_wrong_equipment" | |
t.boolean "employee_taking_short_cut" | |
t.boolean "employee_willful_misconduct" | |
t.boolean "employee_other" | |
t.boolean "factor_equipment_failure" | |
t.boolean "factor_wrong_tools" | |
t.boolean "factor_poor_procedures" | |
t.boolean "factor_workplace_conditions" | |
t.boolean "factor_repetitive_stress" | |
t.boolean "factor_poor_equipment_guarding" | |
t.boolean "factor_poor_maintenance" | |
t.boolean "factor_poor_lighting" | |
t.boolean "factor_unidentified_uncorrected_workplace_hazards" | |
t.boolean "factor_unfamiliar_surroundings" | |
t.boolean "reason_inadequate_rule_enforcement" | |
t.boolean "reason_lack_of_sufficient_training" | |
t.boolean "reason_lack_of_hazard_mitigation" | |
t.boolean "reason_lack_of_supervisor_involvement" | |
t.boolean "reason_plant_equipment_layout" | |
t.boolean "reason_lack_of_accountability" | |
t.boolean "reason_poor_tools_or_maintenance" | |
t.boolean "reason_lack_of_proper_safety_signs" | |
t.datetime "created_at" | |
t.datetime "updated_at" | |
t.boolean "reason_lack_of_employee_involvement" | |
end | |
end | |
### Controller | |
class IncidentReportsController < ApplicationController | |
# GET /incident_reports | |
# GET /incident_reports.xml | |
def index | |
@incident_reports = IncidentReport.all | |
respond_to do |format| | |
format.html # index.html.erb | |
format.xml { render :xml => @incident_reports } | |
end | |
end | |
# GET /incident_reports/1 | |
# GET /incident_reports/1.xml | |
def show | |
@incident_report = IncidentReport.find(params[:id]) | |
respond_to do |format| | |
format.html # show.html.erb | |
format.xml { render :xml => @incident_report } | |
end | |
end | |
# GET /incident_reports/new | |
# GET /incident_reports/new.xml | |
def new | |
@incident_report = IncidentReport.new | |
respond_to do |format| | |
format.html # new.html.erb | |
format.xml { render :xml => @incident_report } | |
end | |
end | |
# GET /incident_reports/1/edit | |
def edit | |
@incident_report = IncidentReport.find(params[:id]) | |
end | |
# POST /incident_reports | |
# POST /incident_reports.xml | |
def create | |
@incident_report = IncidentReport.new(params[:incident_report]) | |
respond_to do |format| | |
if @incident_report.save | |
format.html { redirect_to(@incident_report, :notice => 'Incident report was successfully created.') } | |
format.xml { render :xml => @incident_report, :status => :created, :location => @incident_report } | |
else | |
format.html { render :action => "new" } | |
format.xml { render :xml => @incident_report.errors, :status => :unprocessable_entity } | |
end | |
end | |
end | |
# PUT /incident_reports/1 | |
# PUT /incident_reports/1.xml | |
def update | |
@incident_report = IncidentReport.find(params[:id]) | |
respond_to do |format| | |
if @incident_report.update_attributes(params[:incident_report]) | |
format.html { redirect_to(@incident_report, :notice => 'Incident report was successfully updated.') } | |
format.xml { head :ok } | |
else | |
format.html { render :action => "edit" } | |
format.xml { render :xml => @incident_report.errors, :status => :unprocessable_entity } | |
end | |
end | |
end | |
# DELETE /incident_reports/1 | |
# DELETE /incident_reports/1.xml | |
def destroy | |
@incident_report = IncidentReport.find(params[:id]) | |
@incident_report.destroy | |
respond_to do |format| | |
format.html { redirect_to(incident_reports_url) } | |
format.xml { head :ok } | |
end | |
end | |
end | |
### Views (using Haml) | |
### new.html.haml | |
%h1 New Incident Report | |
= link_to 'Back', incident_reports_path | |
= render 'form' | |
= link_to 'Back', incident_reports_path | |
### _form.html.haml | |
%hr | |
- @show_request = request.method == "GET" && request.path =~ /incident_reports\/\d+$/ | |
-#- Rails.logger.add(5, message = "request.method: #{request.method}") | |
-#- Rails.logger.add(5, message = "request.path: #{request.path}") | |
-#- Rails.logger.add(5, message = "\@show_request: #{@show_request}") | |
-#- Rails.logger.flush | |
= simple_form_for(@incident_report) do |f| | |
- if @incident_report.errors.any? | |
#error_explanation | |
%h2 | |
= pluralize(@incident_report.errors.count, "error") | |
prohibited this incident_report from being saved: | |
%ul | |
- @incident_report.errors.full_messages.each do |msg| | |
%li | |
= msg | |
.body | |
- if !@show_request then | |
.actions | |
= f.submit | |
%div{:class => 'top_section span-24'} | |
%div{:class => 'span-5 border'} | |
= render :partial => "form_flags", :locals => { :f => f } | |
%div{:class => 'span-14 border'} | |
= render :partial => "form_heading", :locals => { :f => f } | |
%div{:class => 'span-5 last'} | |
= render :partial => "form_drug_test", :locals => { :f => f } | |
%div{:class => 'body_section span-24'} | |
%div{:class => 'span-5 border small'} | |
= render :partial => "form_sidebar", :locals => { :f => f } | |
%div{:class => 'span-19 last'} | |
= render :partial => "form_questionnaire", :locals => { :f => f } | |
- if !@show_request then | |
.actions | |
= f.submit | |
%hr | |
### _form_flags.html.haml (first of the various partials; the rest are here as well, for completeness) | |
#upper_left_categories | |
= f.input :flags_near_miss, :label => 'Near miss' | |
= f.input :flags_property_damage, :label => 'Property damage' | |
= f.input :flags_first_aid, :label => 'First aid' | |
= f.input :flags_medical, :label => 'Medical' | |
= f.input :flags_lost_time, :label => 'Lost time' | |
### _form_heading.html.haml | |
%h3 | |
~ "Company Injury, Accident,\n Incident Investigation Form" | |
= f.input :investigator_name, :label => "Name of Investigator:" | |
### _form_drug_test.html.haml | |
#upper_right_drug_test | |
= f.input :drug_alcohol_test_given, :label => "Drug/Alcohol Test Done?<br />", :as => :radio | |
### _form_sidebar.html.haml | |
%hr | |
I. Injury Causative Factors: | |
%br | |
= f.input :employee_following_procedures, :label => 'Was the employee(s)' + "\n" + 'following' + "\n" + 'company rules and procedures?', :as => :radio | |
%hr | |
If <b><u>no</u></b>, was the incident because of: | |
= f.input :employee_lack_of_training, :label => 'Lack of training?' | |
= f.input :employee_not_paying_attention, :label => 'Not paying attention?' | |
= f.input :employee_acting_per_common_practice, :label => 'Acting as per employee common practice?' | |
= f.input :employee_exceeding_physical_capacity, :label => 'Exceeding their physical capacity?' | |
= f.input :employee_using_wrong_equipment, :label => 'Using wrong equipment?' | |
= f.input :employee_taking_short_cut, :label => 'Taking a short cut?' | |
= f.input :employee_willful_misconduct, :label => 'Willful misconduct?' | |
= f.input :employee_other, :label => 'Other?' | |
%hr | |
If <b><u>yes</u></b>, was the incident the result of: | |
%br | |
= f.input :factor_equipment_failure, :label => 'Equipment failure?' | |
= f.input :factor_wrong_tools, :label => 'Wrong tools?' | |
= f.input :factor_poor_procedures, :label => 'Poor proceures?' | |
= f.input :factor_workplace_conditions, :label => 'Workplace conditions?' | |
= f.input :factor_repetitive_stress, :label => 'Repetitive stress (ergonomic factors)?' | |
= f.input :factor_poor_equipment_guarding, :label => 'Poor equipment guardng?' | |
= f.input :factor_poor_maintenance, :label => 'Poor maintenance?' | |
= f.input :factor_poor_lighting, :label => 'Poor lighting?' | |
= f.input :factor_unidentified_uncorrected_workplace_hazards, :label => 'Unidentified or uncorrected workplace hazards?' | |
= f.input :factor_unfamiliar_surroundings, :label => 'Unfamiliar surroundsing / offsite injury?' | |
%hr | |
II. Injury Reason Factors: | |
%br | |
= f.input :reason_inadequate_rule_enforcement, :label => 'Inadequate rule enforcement?' | |
= f.input :reason_lack_of_sufficient_training, :label => 'Lack of relevant, frequent enough, or sufficient training?' | |
= f.input :reason_lack_of_hazard_mitigation, :label => 'Lack of hazard identifying or correction procedures?' | |
= f.input :reason_lack_of_supervisor_involvement, :label => 'Lack of line supervisor involvement?' | |
= f.input :reason_plant_equipment_layout, :label => 'Plant and / or equipment layout?' | |
= f.input :reason_lack_of_accountability, :label => 'Lack of supervisor or employee accountability?' | |
= f.input :reason_lack_of_employee_involvement, :label => 'Lack of employee involvement?' | |
= f.input :reason_poor_tools_or_maintenance, :label => 'Poor tool purchasing and / or maintenance?' | |
= f.input :reason_lack_of_proper_safety_signs, :label => 'Lack of appropriate safety signs or other reminders?' | |
### _form_questionnaire.html.haml | |
%hr | |
= f.input :employee_name, :label => "Employee Name:" | |
= f.input :position, :label => "Position:" | |
= f.input :hire_date, :label => "Hire Date:" | |
%br | |
= f.input :incident_date, :label => "Incident Date:" | |
= f.input :incident_time, :label => "Incident Time:" | |
= f.input :date_first_reported, :label => "Date first reported:" | |
= f.input :supervisor, :label => "Supervisor:" | |
= f.input :department, :label => "Department:" | |
= f.input :witnesses, :label => "Witnesses:" | |
= f.input :incident_location, :label => "Incident location:" | |
= f.input :injury, :label => "1. Describe injury (Nature of injury/Part of body):<br />", | |
:input_html => { :class => 'textarea_small'} | |
= f.input :incident_description, :label => "2. Describe incident fully (what happened?):<br />", | |
:input_html => { :class => 'textarea_small'} | |
= f.input :injury_causative_factor, :label => "3. Identify injury causative factor:<br />", | |
:input_html => { :class => 'textarea_small'} | |
= f.input :injury_causative_factor_reason, :label => "4. Identify reason for causative factor (for example why did tool fail or why was training inadequate?):<br />", | |
:input_html => { :class => 'textarea_small'} | |
= f.input :actions_for_correction_prevention, :label => "5. What specific action should be or has been taken to correct identified reasons (#4) and prevent recurrence (there must always be a specific action taken to prevent recurrence)?<br />", | |
:input_html => { :class => 'textarea_small'} | |
= f.input :responsible_for_correction, :label => "Who is responsible for corrections:" | |
= f.input :correction_expected_completion_date, :label => "Target completion date:" | |
= f.input :correction_actual_completion_date, :label => "Actual completion date:" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment