OSDN Git Service

t#30328:create op import ...and pull
[pettanr/pettanr.git] / app / controllers / demanders_controller.rb
index 92ac27a..405000f 100644 (file)
@@ -9,7 +9,8 @@ class DemandersController < ApplicationController
         format.html # index.html.erb
       end
     else
-      redirect_to new_demander_path, notice: 'Demander not found.'
+      flash[:notice] = I18n.t('demanders.flash.notice.not_found')
+      redirect_to new_demander_path
     end
   end
 
@@ -46,7 +47,8 @@ class DemandersController < ApplicationController
 
     respond_to do |format|
       if @demander.store
-        format.html { redirect_to @demander, notice: 'Demander was successfully created.' }
+        flash[:notice] = I18n.t('flash.notice.created', :model => Demander.model_name.human)
+        format.html { redirect_to @demander }
         format.json { render json: @demander.to_json(Demander.show_json_opt), status: :created, location: @demander }
       else
         format.html { render action: "new" }
@@ -61,7 +63,8 @@ class DemandersController < ApplicationController
     @demander.overwrite @demand_user
     respond_to do |format|
       if @demander.store
-        format.html { redirect_to @demander, notice: 'Demander was successfully updated.' }
+        flash[:notice] = I18n.t('flash.notice.updated', :model => Demander.model_name.human)
+        format.html { redirect_to @demander }
         format.json { head :ok }
       else
         format.html { render action: "edit" }
@@ -74,10 +77,12 @@ class DemandersController < ApplicationController
     @demander = @demand_user.demander
     respond_to do |format|
       if @demander.demander_status.request
-        format.html { redirect_to demanders_path, notice: 'Demander was successfully updated.' }
+        flash[:notice] = I18n.t('demanders.flash.notice.requested')
+        format.html { redirect_to demanders_path }
         format.json { head :ok }
       else
-        format.html { redirect_to demanders_path, notice: 'Demander was not successfully updated.' }
+        flash[:notice] = I18n.t('demanders.flash.notice.not_requested')
+        format.html { redirect_to demanders_path }
         format.json { render json: @demander.errors, status: :unprocessable_entity }
       end
     end
@@ -87,10 +92,12 @@ class DemandersController < ApplicationController
     @demander = Demander.edit(params[:id], @demand_user)
     respond_to do |format|
       if @demander.stop
-        format.html { redirect_to demanders_url, notice: 'Demander was successfully stopped.' }
+        flash[:notice] = I18n.t('demanders.flash.notice.stopped')
+        format.html { redirect_to demanders_url }
         format.json { head :ok }
       else
-        format.html { redirect_to demanders_url, notice: 'Demander was not successfully stopped.' }
+        flash[:notice] = I18n.t('demanders.flash.notice.not_stopped')
+        format.html { redirect_to demanders_url }
         format.json { render json: @demander.errors, status: :unprocessable_entity }
       end
     end