Sha256: 92c007f15d61a83ae3f0094cfa9c2f595dcfa7ca2c9185b3dd24cd68863134e5

Contents?: true

Size: 439 Bytes

Versions: 12

Compression:

Stored size: 439 Bytes

Contents

module Applicat::Mvc::Controller::Resource
  def self.included(base)
    base.class_eval do
      helper_method :parent, :resource
      
      include InstanceMethods
    end
  end
  
  module InstanceMethods
    def autocomplete
      render json: (
        params[:controller].classify.constantize.
        select(:name).order(:name).where("name LIKE ?", "%#{params[:term]}%").
        map(&:name)
      ), root: false
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
voluntary-0.7.1 lib/applicat/mvc/controller/resource.rb
voluntary-0.7.0 lib/applicat/mvc/controller/resource.rb
voluntary-0.6.0 lib/applicat/mvc/controller/resource.rb
voluntary-0.5.2 lib/applicat/mvc/controller/resource.rb
voluntary-0.5.1 lib/applicat/mvc/controller/resource.rb
voluntary-0.5.0 lib/applicat/mvc/controller/resource.rb
voluntary-0.4.0 lib/applicat/mvc/controller/resource.rb
voluntary-0.3.0 lib/applicat/mvc/controller/resource.rb
voluntary-0.2.4 lib/applicat/mvc/controller/resource.rb
voluntary-0.2.3 lib/applicat/mvc/controller/resource.rb
voluntary-0.2.2 lib/applicat/mvc/controller/resource.rb
voluntary-0.2.1 lib/applicat/mvc/controller/resource.rb