Sha256: 2e7ac492bfe394235e4cdf098e89f9c58b77e314177711c15338c177c6ae634f

Contents?: true

Size: 1.07 KB

Versions: 48

Compression:

Stored size: 1.07 KB

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
      if request.format == "json"      
        render :json => {:success => true} 
      else
        respond_with(@photo)
      end
  end
  
  def destroy
      @photo.destroy
      respond_with(@photo)
  end
  
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
fullstack-cms-0.4.6 app/controllers/admin/photos_controller.rb
fullstack-cms-0.4.5 app/controllers/admin/photos_controller.rb
fullstack-cms-0.4.4 app/controllers/admin/photos_controller.rb
fullstack-cms-0.3.8.fix app/controllers/admin/photos_controller.rb
fullstack-cms-0.4.3 app/controllers/admin/photos_controller.rb
fullstack-cms-0.4.2 app/controllers/admin/photos_controller.rb
fullstack-cms-0.4.1 app/controllers/admin/photos_controller.rb
fullstack-cms-0.3.39 app/controllers/admin/photos_controller.rb
fullstack-cms-0.3.38 app/controllers/admin/photos_controller.rb
fullstack-cms-0.3.37 app/controllers/admin/photos_controller.rb
fullstack-cms-0.3.36 app/controllers/admin/photos_controller.rb
fullstack-cms-0.3.35 app/controllers/admin/photos_controller.rb
fullstack-cms-0.3.34 app/controllers/admin/photos_controller.rb
fullstack-cms-0.3.33 app/controllers/admin/photos_controller.rb
fullstack-cms-0.3.32 app/controllers/admin/photos_controller.rb
fullstack-cms-0.3.31 app/controllers/admin/photos_controller.rb
fullstack-cms-0.3.30 app/controllers/admin/photos_controller.rb
fullstack-cms-0.3.29 app/controllers/admin/photos_controller.rb
fullstack-cms-0.3.28 app/controllers/admin/photos_controller.rb
fullstack-cms-0.3.27 app/controllers/admin/photos_controller.rb