Class: Boss::Admin::ResourcesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Boss::Admin::ResourcesController
- Defined in:
- app/controllers/boss/admin/resources_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/boss/admin/resources_controller.rb', line 8 def create @file = Boss::Resource.new params[:resource] if @file.save render :json => [{ :url => @file.resource.url.to_s, :thumbnail_url => ActionController::Base.helpers.asset_path("boss/icons/avi/avi-48_32.png"), :name => @file.resource.instance.attributes["resource_file_name"], :delete_url => admin_resource_path(@file), :delete_type => "DELETE" }], :content_type => 'text/html' else render :json => { :result => 'error'}, :content_type => 'text/html' end end |
#destroy ⇒ Object
23 24 25 26 27 |
# File 'app/controllers/boss/admin/resources_controller.rb', line 23 def destroy @file = Boss::Resource.find params[:id] @file.destroy render :json => { :result => true }, :content_type => 'application/json' end |
#index ⇒ Object
4 5 6 |
# File 'app/controllers/boss/admin/resources_controller.rb', line 4 def index @resources = Boss::Resource.resources_for_index end |
#load ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/boss/admin/resources_controller.rb', line 29 def load @resources = Boss::Resource.resources_for_index({ starts_at: params[:starts_at] }) html_str = render_to_string( partial: "boss/admin/resources/resource", collection: @resources) respond_to do |format| format.json { render json: { html: html_str, has_more: !@resources.empty?, new_start: (@resources.last) ? @resources.last.id : nil } } end end |