OSDN Git Service

t#29034:create overwrite
[pettanr/pettanr.git] / app / controllers / stories_controller.rb
index 530a3eb..15d48ca 100644 (file)
@@ -47,11 +47,10 @@ class StoriesController < ApplicationController
   # GET /stories/new.json
   def new
     @story = Story.new 
-    @story.supply_default @author
-    @form_opt = {}
+    @story.supply_default
     respond_to do |format|
       format.html # new.html.erb
-      format.js { @form_opt = {:remote => true} ;  render action: "new" }
+      format.js
       format.json { render json: @story }
     end
   end
@@ -70,8 +69,9 @@ class StoriesController < ApplicationController
   # POST /stories.json
   def create
     @story = Story.new 
-    @story.supply_default @author
+    @story.supply_default
     @story.attributes = params[:story]
+    @story.overwrite @author
     
     respond_to do |format|
       if @story.store
@@ -88,9 +88,9 @@ class StoriesController < ApplicationController
   # PUT /stories/1.json
   def update
     @story = Story.show(params[:id], @author)
-    @story.author_id = @author.id
     ot = @story.t
     @story.attributes = params[:story]
+    @story.overwrite @author
     respond_to do |format|
       if @story.store ot
         format.html { redirect_to action: :show, id: @story.comic_id }