From: yasushiito Date: Tue, 27 Nov 2012 09:33:09 +0000 (+0900) Subject: t#30199:update i18n error caption X-Git-Url: http://git.osdn.net/view?p=pettanr%2Fpettanr.git;a=commitdiff_plain;h=c1ce32fbd93b9412ac557fe4d2e53887708caafd t#30199:update i18n error caption --- diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e416327e..9b27e322 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -23,4 +23,5 @@ module ApplicationHelper def t_selected_item(name, index) t(MagicNumber[name][index][0]) end + end diff --git a/app/views/artists/_form.html.erb b/app/views/artists/_form.html.erb index 74802c09..ae35d64d 100644 --- a/app/views/artists/_form.html.erb +++ b/app/views/artists/_form.html.erb @@ -1,15 +1,5 @@ <%= form_for(@artist) do |f| %> - <% if @artist.errors.any? %> -
-

<%= pluralize(@artist.errors.count, "error") %> prohibited this artist from being saved:

- - -
- <% end %> + <%= render 'system/error_explanation', :obj => @artist %>
<%= f.label :name %>
diff --git a/app/views/authors/_form.html.erb b/app/views/authors/_form.html.erb index d15a03de..f4a8a3fe 100644 --- a/app/views/authors/_form.html.erb +++ b/app/views/authors/_form.html.erb @@ -1,15 +1,5 @@ <%= form_for(@au) do |f| %> - <% if @au.errors.any? %> -
-

<%= pluralize(@au.errors.count, "error") %> prohibited this author from being saved:

- -
    - <% @au.errors.full_messages.each do |msg| %> -
  • <%= msg %>
  • - <% end %> -
-
- <% end %> + <%= render 'system/error_explanation', :obj => @au %>
<%= f.label :name %>
diff --git a/app/views/comics/_form.html.erb b/app/views/comics/_form.html.erb index 8a7ab69b..8f4ca294 100644 --- a/app/views/comics/_form.html.erb +++ b/app/views/comics/_form.html.erb @@ -1,15 +1,5 @@ <%= form_for(@comic) do |f| %> - <% if @comic.errors.any? %> -
-

<%= pluralize(@comic.errors.count, "error") %> prohibited this comic from being saved:

- -
    - <% @comic.errors.full_messages.each do |msg| %> -
  • <%= msg %>
  • - <% end %> -
-
- <% end %> + <%= render 'system/error_explanation', :obj => @comic %>
<%= f.label :author_id %>
diff --git a/app/views/original_picture_license_groups/_form.html.erb b/app/views/original_picture_license_groups/_form.html.erb index e3413f11..b9b850c6 100644 --- a/app/views/original_picture_license_groups/_form.html.erb +++ b/app/views/original_picture_license_groups/_form.html.erb @@ -1,15 +1,5 @@ <%= form_for(@original_picture_license_group) do |f| %> - <% if @original_picture_license_group.errors.any? %> -
-

<%= pluralize(@original_picture_license_group.errors.count, "error") %> prohibited this comic from being saved:

- -
    - <% @original_picture_license_group.errors.full_messages.each do |msg| %> -
  • <%= msg %>
  • - <% end %> -
-
- <% end %> + <%= render 'system/error_explanation', :obj => @original_picture_license_group %> diff --git a/app/views/panels/_form.html.erb b/app/views/panels/_form.html.erb index 08e6d608..81965fd5 100644 --- a/app/views/panels/_form.html.erb +++ b/app/views/panels/_form.html.erb @@ -1,15 +1,5 @@ <%= form_tag( {:controller => 'panels',:action => "create"}) do %> - <% if @panel.errors.any? %> -
-

<%= pluralize(@panel.errors.count, "error") %> prohibited this panel from being saved:

- -
    - <% @panel.errors.full_messages.each do |msg| %> -
  • <%= msg %>
  • - <% end %> -
-
- <% end %> + <%= render 'system/error_explanation', :obj => @panel %> <%= text_field_tag "json" %> <%= submit_tag 'upload' -%> <% end -%> diff --git a/app/views/stories/_editform.html.erb b/app/views/stories/_editform.html.erb index 9cc6dd41..73f55bf2 100644 --- a/app/views/stories/_editform.html.erb +++ b/app/views/stories/_editform.html.erb @@ -1,15 +1,5 @@ <%= form_for(@story) do |f| %> - <% if @story.errors.any? %> -
-

<%= pluralize(@story.errors.count, "error") %> prohibited this comic from being saved:

- -
    - <% @story.errors.full_messages.each do |msg| %> -
  • <%= msg %>
  • - <% end %> -
-
- <% end %> + <%= render 'system/error_explanation', :obj => @story %>
<%= f.hidden_field :comic_id %> diff --git a/app/views/stories/_newform.html.erb b/app/views/stories/_newform.html.erb index f7b57490..7ec5e4a8 100644 --- a/app/views/stories/_newform.html.erb +++ b/app/views/stories/_newform.html.erb @@ -1,15 +1,5 @@ <%= form_for(@story) do |f| %> - <% if @story.errors.any? %> -
-

<%= pluralize(@story.errors.count, "error") %> prohibited this comic from being saved:

- -
    - <% @story.errors.full_messages.each do |msg| %> -
  • <%= msg %>
  • - <% end %> -
-
- <% end %> + <%= render 'system/error_explanation', :obj => @story %>
<%= f.number_field :comic_id %> diff --git a/app/views/system/_error_explanation.html.erb b/app/views/system/_error_explanation.html.erb new file mode 100644 index 00000000..2043c07c --- /dev/null +++ b/app/views/system/_error_explanation.html.erb @@ -0,0 +1,18 @@ +<% if obj.errors.any? %> +
+

+ <%= + if obj.errors.size == 1 + t('activerecord.errors.template.header.one', :model => obj.class.model_name.human) + else + t('activerecord.errors.template.header.other', :model => obj.class.model_name.human, :count => obj.errors.size) + end + %> +

+
    + <% obj.errors.full_messages.each do |msg| %> +
  • <%= msg %>
  • + <% end %> +
+
+<% end %>