Sha256: 221583249606786dd60f0f4ebaf14a6894c007c032f45c7263ea0653ae1a1ada
Contents?: true
Size: 1.51 KB
Versions: 18
Compression:
Stored size: 1.51 KB
Contents
# frozen_string_literal: true module Cmor::Seo class ItemsController < Cmor::Core::Backend::ResourcesController::Base include Rao::ResourcesController::ActsAsPublishedConcern def self.resource_class Cmor::Seo::Item end module AutocompleteConcern extend ActiveSupport::Concern def autocomplete_resource resource_class_name = params[:resource_class_name] term = params[:term] || "" autocomplete_options = autocomplete_options_for(resource_class_name) if autocomplete_options.present? resources = autocomplete_options[:scope].call(term).all results = resources.collect do |resource| { id: resource.send(autocomplete_options[:id_method]), text: resource.send(autocomplete_options[:text_method]) } end else results = [] end respond_to do |format| format.json do render json: { results: results } end end end private def autocomplete_options_for(resource_class_name) Cmor::Seo::Configuration.resources_autocomplete_options[resource_class_name][:autocomplete_options] end end include AutocompleteConcern private def load_collection_scope super.eager_load(:meta_tags) end def permitted_params params.require(:item).permit(:resource_type, :resource_id, :path, :published, meta_tags_attributes: [:id, :name, :content, :published, :_destroy]) end end end
Version data entries
18 entries across 18 versions & 1 rubygems