Sha256: a1aa9298713ce59fe9182387eca53690c6f59efd007cc33c853235908d563076

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

module RailsAdminContentBuilder
  # This class
  class ContentBuilderController < ::ApplicationController
    def search_content
      content_builder = RailsAdminContentBuilder::ContentBuilder
      @content_builder = content_builder.order('date_publish desc')
                                        .limit(10)
                                        .search(params[:term])
      if @content_builder
        render json: @content_builder.to_json(include: {content_builder_category: {only: [:name, :slug]}})
      else
        render json: @content_builder.errors
      end
    end

    def create_images
      @content_builder = ContentBuilder.find(params[:id])
      @image = @content_builder.content_builder_images
                               .create(image: params[:content_builder_image])
      if @image.valid?
        render json: find_image(@image.id)
      else
        render json: @image.errors
      end
    end

    private

    def find_image(id)
      ContentBuilderImage.find(id).image.to_json
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails_admin_content_builder-1.3.0 app/controllers/rails_admin_content_builder/content_builder_controller.rb
rails_admin_content_builder-1.2.0 app/controllers/rails_admin_content_builder/content_builder_controller.rb
rails_admin_content_builder-1.1.0 app/controllers/rails_admin_content_builder/content_builder_controller.rb
rails_admin_content_builder-1.0.6 app/controllers/rails_admin_content_builder/content_builder_controller.rb
rails_admin_content_builder-1.0.5 app/controllers/rails_admin_content_builder/content_builder_controller.rb