OSDN Git Service

add lg_id in resource picture
[pettanr/pettanr.git] / app / controllers / application_controller.rb
index 8169f6f..00f2d46 100644 (file)
@@ -178,6 +178,10 @@ class ApplicationController < ActionController::Base
     format.json { render json: @item.to_json(@my_model_class.show_json_opt) }
   end
   
+  def show_json_format_for_root format
+    format.json { render json: @item.to_json(@my_model_class.show_json_opt_for_root) }
+  end
+  
   def set_new
     set_model
     @item = @my_model_class.new
@@ -213,10 +217,10 @@ class ApplicationController < ActionController::Base
     render_form
   end
   
-  def created_html_format format
+  def created_html_format format, redirect_url = nil
     format.html {
       flash[:notice] = I18n.t('flash.notice.created', :model => @my_model_class.model_name.human)
-      redirect_to @item
+      redirect_to (redirect_url ? redirect_url : @item)
     }
   end
   
@@ -239,10 +243,10 @@ class ApplicationController < ActionController::Base
     }
   end
   
-  def render_create
+  def render_create redirect_url = nil
     if @item.save
       respond_to do |format|
-        created_html_format format
+        created_html_format format, redirect_url
         created_json_format format
       end
     else
@@ -281,10 +285,10 @@ class ApplicationController < ActionController::Base
     end
   end
   
-  def updated_html_format format
+  def updated_html_format format, redirect_url = nil
     format.html {
       flash[:notice] = I18n.t('flash.notice.updated', :model => @my_model_class.model_name.human)
-      redirect_to @item
+      redirect_to (redirect_url ? redirect_url : @item)
     }
   end
   
@@ -307,10 +311,10 @@ class ApplicationController < ActionController::Base
     }
   end
   
-  def render_update
+  def render_update redirect_url = nil
     if @item.save
       respond_to do |format|
-        updated_html_format format
+        updated_html_format format, redirect_url
         updated_json_format format
       end
     else