Class: Admin::AssetsController
- Inherits:
-
ResourceController
- Object
- ResourceController
- Admin::AssetsController
- Defined in:
- app/controllers/admin/assets_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/admin/assets_controller.rb', line 27 def create @assets, @page_attachments = [], [] params[:asset][:asset].to_a.each do |uploaded_asset| @asset = Asset.create(:group => params[:asset][:group], :asset => uploaded_asset, :title => params[:asset][:title], :caption => params[:asset][:caption]) if params[:for_attachment] @page = Page.find_by_id(params[:page_id]) || Page.new @page_attachments << @page_attachment = @asset..build(:page => @page) end @assets << @asset end if params[:for_attachment] render :partial => 'admin/page_attachments/attachment', :collection => @page_attachments else response_for :create end end |
#index ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/admin/assets_controller.rb', line 4 def index assets = Asset.scoped({:order => "created_at DESC"}) @term = params[:search] || '' assets = assets.matching(@term) if @term && !@term.blank? @types = params[:filter] || [] if @types.include?('all') params[:filter] = nil elsif @types.any? assets = assets.of_types(@types) end @assets = paginated? ? assets.paginate(pagination_parameters) : assets.all respond_to do |format| format.html { render } format.js { @page = Page.find_by_id(params[:page_id]) render :partial => 'asset_table', :locals => {:with_pagination => !!@page} } end end |
#refresh ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'app/controllers/admin/assets_controller.rb', line 44 def refresh if params[:id] @asset = Asset.find(params[:id]) @asset.asset.reprocess! flash[:notice] = t('clipped_extension.thumbnails_refreshed') redirect_to edit_admin_asset_path(@asset) else render end end |
#regenerate ⇒ Object
60 61 62 63 64 |
# File 'app/controllers/admin/assets_controller.rb', line 60 def regenerate Asset.all.each { |asset| asset.asset.reprocess! } flash[:notice] = t('clipped_extension.all_thumbnails_refreshed') redirect_to admin_assets_path end |