Commit 78aef7f9 authored by pei-chi.huang's avatar pei-chi.huang
Browse files

style result button

parent e7d66feb
......@@ -56,11 +56,15 @@ class SamplesController < ApplicationController
def update
sample = Sample.find(params[:id])
if sample.update_attributes(sample_params)
sample.touch
flash[:success] = "Sample updated"
else
flash[:danger] = sample.errors.full_messages.to_sentence
unless sample_params.nil?
if sample.update_attributes(sample_params)
sample.touch
flash[:success] = "Sample updated"
else
flash[:danger] = sample.errors.full_messages.to_sentence
end
else
flash[:warning] = "no results"
end
redirect_to URI(request.referer).path + "?display_sample=#{sample.id}"
......@@ -120,7 +124,7 @@ class SamplesController < ApplicationController
def sample_params
keys=Sample::ELEMENTS.keys
params.require(:sample).permit(:name, :formula, results_attributes: [:id, :_destroy, :element_C,:element_H,:element_N,:element_S])
params.require(:sample).permit(:name, :formula, results_attributes: [:id, :_destroy, :element_C,:element_H,:element_N,:element_S]) if params[:sample].present?
end
def correct_user
......
......@@ -12,7 +12,7 @@ module SamplesHelper
elsif e == 0
'NaN'
else
((m - e).abs/e).round(2)
(((m - e).abs/e) * 100).round(2)
end
end
......
......@@ -46,14 +46,14 @@
<%= link_to_add_association 'Add Result', f, :results,
'data-association-insertion-node' => "#resultTable ",
'data-association-insertion-method' => "append",
:style=>'color: Black;' , :class=>"btn btn-block btn-secondary" %>
:style=>'color: Black;' , :class=>"btn btn-block btn-info" %>
</div>
</fieldset>
<div class="links" style="margin-left:30px">
<br>
<%= f.submit %>
<%= f.submit "Update Sample", class: "btn btn-success" %>
</div>
<% end %>
<script>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment