Sha256: 180cc70939747cfe77d91fbb109874d602bb77e7177b1a85a43f890b2e50c313

Contents?: true

Size: 901 Bytes

Versions: 1

Compression:

Stored size: 901 Bytes

Contents

module ScrivitoResourcebrowser
  class ResourcebrowserController < ApplicationController
    # Return JSON responses without layout information.
    layout false

    # Render a JSON response that holds the resource browser inspector markup. The inspector either
    # renders the details view for the selected object, or a fallback view that is located under
    # 'app/views/obj/details'.
    def inspector
      @obj = Obj.find(params[:id])

      options = {
        layout: 'scrivito_resourcebrowser/inspector',
      }

      content = begin
        render_to_string(details_view_template(@obj), options)
      rescue ActionView::MissingTemplate
        render_to_string('scrivito_resourcebrowser/obj/details', options)
      end

      render json: { content: content }
    end

    private

    def details_view_template(obj)
      "#{obj.obj_class_name.underscore}/details"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scrivito_resourcebrowser-0.0.6 app/controllers/scrivito_resourcebrowser/resourcebrowser_controller.rb