OSDN Git Service

fix editor
[pettanr/pettanr.git] / app / controllers / authors_controller.rb
index b9956d6..f45feb6 100644 (file)
@@ -18,7 +18,6 @@ class AuthorsController < ApplicationController
   
   def show_html_format format
     format.html {
-      @author = @item
     }
   end
   
@@ -36,53 +35,26 @@ class AuthorsController < ApplicationController
   end
   
   def new
-    @author = Author.new
-    @author.supply_default 
-
-    respond_to do |format|
-      format.html
-      format.js
-      format.json { render json: @au.to_json(Author.show_json_opt) }
-    end
+    form_new
   end
-
+  
   def edit
-    @author = Author.edit(params[:id], @operators)
+    form_edit
   end
-
+  
   def create
-    @author = Author.new()
-    @author.supply_default 
-    @author.attributes = params[:author]
-    @author.overwrite @operators
-    respond_to do |format|
-      if @author.save
-        flash[:notice] = I18n.t('flash.notice.created', :model => Author.model_name.human)
-        format.html { redirect_to root_path }
-        format.json { render json: @author.to_json(Author.show_json_opt), status: :created }
-      else
-        flash[:notice] = I18n.t('flash.notice.not_created', :model => Author.model_name.human)
-        format.html { render action: "new" }
-        format.json { render json: @au.errors, status: :unprocessable_entity }
-      end
-    end
+    set_model
+    @item = @my_model_class.new
+    @item.supply_default 
+    @item.attributes = params[@my_model_class.item_name]
+    @item.overwrite @operators
+    render_create root_path
   end
-
+  
   def update
-    @author = Author.edit(params[:id], @operators)
-    @author.attributes = params[:author]
-    @author.overwrite @operators
-
-    respond_to do |format|
-      if @author.save
-        flash[:notice] = I18n.t('flash.notice.updated', :model => Author.model_name.human)
-        format.html { redirect_to '/home/configure' }
-        format.json { head :ok }
-      else
-        flash[:notice] = I18n.t('flash.notice.not_updated', :model => Author.model_name.human)
-        format.html { render action: "edit" }
-        format.json { render json: @author.errors, status: :unprocessable_entity }
-      end
-    end
+    set_edit
+    @item.attributes = params[@my_model_class.item_name]
+    @item.overwrite @operators
+    render_update '/home/configure'
   end
 end