Sha256: 315168bf8419d7841e2ba3873b1ad9eaa460c2db08bb27d86d2dd4a881126e46

Contents?: true

Size: 987 Bytes

Versions: 40

Compression:

Stored size: 987 Bytes

Contents

class Admin::PhotosController < Admin::BaseController
  respond_to :html, :js  
  layout false
  
  def create
    photographable_id = params[:photographable_id]
    photographable_class = params[:photographable_type].constantize
    @photographable = photographable_class.find(photographable_id)
    
      if @photographable.respond_to?(:photos) # <- has_many :photos
        @photo = @photographable.photos.build({:image => params[:file]})
      else # <- has_one :photo
        @photo = @photographable.build_photo({:image => params[:file]})
      end
      
      if @photo.save
        respond_with(@photo)
      else
        render :status => 500
      end

  end

  def search
    @photos = Photo.tagged_with(params[:q]).page(params[:page])
    respond_with(@photos)
  end
  
  def edit
  end
  
  def update
      @photo.attributes = params[:photo]
      @photo.save
      respond_with(@photo)
  end
  
  def destroy
      @photo.destroy
      respond_with(@photo)
  end
  
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
fullstack-cms-0.2.32.fix app/controllers/admin/photos_controller.rb
fullstack-cms-0.2.31 app/controllers/admin/photos_controller.rb
fullstack-cms-0.2.30 app/controllers/admin/photos_controller.rb
fullstack-cms-0.2.29 app/controllers/admin/photos_controller.rb
fullstack-cms-0.2.28 app/controllers/admin/photos_controller.rb
fullstack-cms-0.2.27 app/controllers/admin/photos_controller.rb
fullstack-cms-0.2.26 app/controllers/admin/photos_controller.rb
fullstack-cms-0.2.25 app/controllers/admin/photos_controller.rb
fullstack-cms-0.2.24 app/controllers/admin/photos_controller.rb
fullstack-cms-0.2.23 app/controllers/admin/photos_controller.rb
fullstack-cms-0.2.22 app/controllers/admin/photos_controller.rb
fullstack-cms-0.2.21 app/controllers/admin/photos_controller.rb
fullstack-cms-0.2.20 app/controllers/admin/photos_controller.rb
fullstack-cms-0.2.19 app/controllers/admin/photos_controller.rb
fullstack-cms-0.2.18 app/controllers/admin/photos_controller.rb
fullstack-cms-0.2.17 app/controllers/admin/photos_controller.rb
fullstack-cms-0.2.16 app/controllers/admin/photos_controller.rb
fullstack-cms-0.2.15 app/controllers/admin/photos_controller.rb
fullstack-cms-0.2.14 app/controllers/admin/photos_controller.rb
fullstack-cms-0.2.13 app/controllers/admin/photos_controller.rb