module LookupBy::Hooks::Formtastic

Public Instance Methods

input_with_lookup(method, options = {}) click to toggle source
# File lib/lookup_by/hooks/formtastic.rb, line 13
def input_with_lookup(method, options = {})
  klass = object.class

  if klass.respond_to?(:lookups) && klass.lookups.include?(method.to_sym)
    target = method.to_s.classify.constantize

    options[:collection] ||= target.pluck(target.lookup.field) if target.lookup.has_cache?
  end

  input_without_lookup(method, options)
end