Created
August 18, 2015 07:55
-
-
Save soilforlifeforms/ce4f158cac8eee2751a6 to your computer and use it in GitHub Desktop.
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
class GroupEvaluationsController <ApplicationController | |
def new | |
session[:group_evaluation_params] ||= {} | |
@group = Group.all | |
@group_evaluation = GroupEvaluation.new | |
end | |
def edit | |
end | |
def index | |
@group_evaluations = GroupEvaluation.all | |
end | |
def create | |
session[:group_evaluation_params].deep_merge!(params[:group_evaluation]) if params[:group_evaluation] | |
@group_evaluation = GroupEvaluation.new(session[:group_evaluation_params]) | |
@group_evaluation.current_step = session[:group_evaluation_step] | |
if params[:back_button] | |
@group_evaluation.previous_step | |
elsif @group_evaluation.last_step? | |
@group_evaluation.save | |
else | |
@group_evaluation.next_step | |
end | |
session[:group_evaluation_step] = @group_evaluation.current_step | |
if @group_evaluation.new_record? | |
render "new" | |
else | |
session[:group_evaluation_step] = session[:group_evaluation_params] = nil | |
flash[:notice] = "evaluation saved" | |
redirect_to :action => "new" | |
end | |
end | |
private | |
def group_evaluation_params | |
params.require(:group_evaluation).permit(:group_id, :date_answered, :training_good, | |
:training_information_helpful, :training_support_helpful, :training_qualitative_positive, | |
:training_qualitative_negative, :trainer_good, :trainer_understandable, :trainer_helpful, | |
:trainer_approachable, :trainer_qualitative_positive, :trainer_qualitative_negative, | |
:msc_qualitative, :final_notes, :date_answered, :training_understandable) | |
end | |
end |
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
<div class="panel panel-default"> | |
<h2> Listing group evaluations </h2> | |
</p> | |
<table class="table"> | |
<thead> | |
<tr> | |
<th>Group name</th> | |
<th>Gardener Name</th> | |
<th colspan="3"></th> | |
</tr> | |
</thead> | |
<tbody> | |
<% @group_evaluations.each do |evaluations| %> | |
<tr> | |
<td><%= evaluations.group.group_name %></td> | |
<td><%= evaluations.group.group_evaluations.count %> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment