adds error messages to account edit

This commit is contained in:
rgarcia
2015-08-07 17:47:53 +02:00
parent 076448ec80
commit a65396886a
2 changed files with 17 additions and 2 deletions

View File

@@ -7,8 +7,11 @@ class AccountController < ApplicationController
end
def update
flash[:notice] = t("flash.actions.save_changes.notice") if @account.update(account_params)
redirect_to account_path
if @account.update(account_params)
redirect_to account_path, notice: t("flash.actions.save_changes.notice")
else
render :show
end
end
private

View File

@@ -3,6 +3,18 @@
<h1><%= t("account.show.title") %></h1>
<%= form_for @account, as: :account, url: account_path do |f| %>
<% if @account.errors.any? %>
<div id="error_explanation" class="alert-box alert radius">
<p><strong><%= pluralize(@account.errors.count, t("debates.form.error"), t("debates.form.errors")) %> <%= t("debates.form.not_saved") %></strong></p>
<ul>
<% @account.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="row">
<div class="small-12 medium-6 column">
<%= f.label :first_name, t("account.show.first_name_label") %>