OSDN Git Service

fix: rp update faild
[pettanr/pettanr.git] / app / controllers / resource_pictures_controller.rb
index 549e779..6850873 100644 (file)
@@ -5,7 +5,7 @@ class ResourcePicturesController < ApplicationController
   else
     before_action :authenticate_resource_reader, :only => [
       :index, :show, :credit, 
-      :by_original_picture, :by_license_group, :by_license, :by_artist
+      :by_original_picture, :by_license_group, :by_license, :by_artist, :search
     ]
     before_action :authenticate_user, :only => [:new, :create, :update, :destroy]
     before_action :authenticate_artist, :only => [:new, :create, :update, :destroy]
@@ -16,19 +16,19 @@ class ResourcePicturesController < ApplicationController
   end
   
   def by_original_picture
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_license_group
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_license
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_artist
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show_html_format format
@@ -78,6 +78,7 @@ class ResourcePicturesController < ApplicationController
     else
       @item.permit_params(params)
     end
+    @prm.delete 'id'
     @item.attributes = @prm
     @item.overwrite @original_picture
     @item.boosts 'post'
@@ -106,4 +107,13 @@ class ResourcePicturesController < ApplicationController
     end
   end
   
+  def search
+    @resource_pictures = ResourcePicture.find_by_md5(params[:md5])
+    
+    respond_to do |format|
+      format.html
+      format.json { render json: @resource_pictures.to_json }
+    end
+  end
+  
 end