Sha256: 6facebc91d93e353104203c4d2fae8356b76b7e0bfb71c6faf18dc04e1b4e044

Contents?: true

Size: 426 Bytes

Versions: 6

Compression:

Stored size: 426 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)
      )
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
voluntary-0.2.0 lib/applicat/mvc/controller/resource.rb
voluntary-0.1.0 lib/applicat/mvc/controller/resource.rb
voluntary-0.1.0.rc4 lib/applicat/mvc/controller/resource.rb
voluntary-0.1.0.rc3 lib/applicat/mvc/controller/resource.rb
voluntary-0.1.0.rc2 lib/applicat/mvc/controller/resource.rb
voluntary-0.1.0.rc1 lib/applicat/mvc/controller/resource.rb