app/controllers/admin/pictures_controller.rb
# Copy a picture to other Gallery
# get request => View
# post request => Copy and redirect
Copy a picture to other Gallery
get request => View
post request => Copy and redirect
Copy a picture to other Gallery get request = > View post request = > Copy and redirect
def copy
    @picture = Picture.find_by_permalink(params[:picture_id])
    if request.post? && !request.xhr?
      @gallery = Gallery.find(params[:picture][:to_gallery_id])
      Import.create(:path => File.join(RAILS_ROOT, 'public', @picture.public_filename),
                   :gallery_id => @gallery.id,
                   :total => 1)
      redirect_to admin_gallery_url(@gallery)
      return
    else
      @other_galleries =  Gallery.other_galleries(@picture)
    end
  end
def copy @picture = Picture . find_by_permalink ( params [ :picture_id ] ) if request . post? && ! request . xhr? @gallery = Gallery . find ( params [ :picture ] [ :to_gallery_id ] ) Import . create ( :path => File . join ( RAILS_ROOT , 'public' , @picture . public_filename ) , :gallery_id => @gallery . id , :total => 1 ) redirect_to admin_gallery_url ( @gallery ) return else @other_galleries = Gallery . other_galleries ( @picture ) end end
Copy a picture to other Gallery
get request => View
post request => Copy and redirect
Copy a picture to other Gallery get request = > View post request = > Copy and redirect