OSDN Git Service

t#29312:any update
[pettanr/pettanr.git] / app / controllers / artists_controller.rb
index ae96dd9..dec44ed 100644 (file)
@@ -56,6 +56,7 @@ layout 'test'
   # GET /artists/new.json
   def new
     @artist = Artist.new
+    @artist.supply_default 
 
     respond_to do |format|
       format.html # new.html.erb
@@ -66,14 +67,16 @@ layout 'test'
 
   # GET /artists/1/edit
   def edit
-    @artist = Artist.find(params[:id])
+    @artist = Artist.edit(params[:id], @author)
   end
 
   # POST /artists
   # POST /artists.json
   def create
-    @artist = Artist.new(params[:artist])
-    @artist.author_id = @author.id
+    @artist = Artist.new()
+    @artist.supply_default 
+    @artist.attributes = params[:artist]
+    @artist.overwrite @author
     respond_to do |format|
       if @artist.save
         format.html { redirect_to @artist, notice: 'Artist was successfully created.' }
@@ -88,10 +91,12 @@ layout 'test'
   # PUT /artists/1
   # PUT /artists/1.json
   def update
-    @artist = Artist.find(params[:id])
+    @artist = Artist.edit(params[:id], @author)
+    @artist.attributes = params[:artist]
+    @artist.overwrite @author
 
     respond_to do |format|
-      if @artist.update_attributes(params[:artist])
+      if @artist.save
         format.html { redirect_to @artist, notice: 'Artist was successfully updated.' }
         format.json { head :ok }
       else
@@ -104,7 +109,7 @@ layout 'test'
   # DELETE /artists/1
   # DELETE /artists/1.json
   def destroy
-    @artist = Artist.find(params[:id])
+    @artist = Artist.edit(params[:id], @author)
     @artist.destroy
 
     respond_to do |format|