Class: RailsAdminFeaturedContent::FeaturedContentController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/rails_admin_featured_content/featured_content_controller.rb

Instance Method Summary collapse

Instance Method Details

#create_imagesObject



19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/rails_admin_featured_content/featured_content_controller.rb', line 19

def create_images
  @featured_content = FeaturedContent.find(params[:id])
  @image = @featured_content.featured_content_images
  .create(image: params[:featured_content_image])

  if @image
    render json: find_image(@image.id)
  else
    render json: @image.errors
  end
end

#search_contentObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/rails_admin_featured_content/featured_content_controller.rb', line 3

def search_content
  @content_builder = RailsAdminContentBuilder::ContentBuilder
  .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