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