Module: Filch

Defined in:
lib/filch.rb,
lib/filch/error.rb,
lib/filch/engine.rb,
lib/filch/version.rb,
lib/filch/datalist.rb,
lib/filch/model_find.rb,
lib/filch/ransack_plus.rb

Overview

The Filch Gem

the Filch Gem is entirely based on the ransack gem Filch allows for easy advanced form building.

Features

Filch::Templates

The Filch::Templates object is used when generating the form(s).

Filch::Datalist

Text fields are linked to a <datalist>. Uses javascript to update the list with Filch::Datalist.quick

Filch::RansackPlus

Certain methods I couldn’t do with Ransack/Arel.

Defined Under Namespace

Classes: Associations, Attributes, Datalist, Engine, Error, ModelFind, RansackPlus, Scopes, Template, Templates

Constant Summary collapse

VERSION =
'0.1.0'.freeze

Class Method Summary collapse

Class Method Details

.datalist(model_name, attr, params) ⇒ Object

calls the Filch::Datalist.quick method. model_name is a String representing the name of the model. attr is a String representing the attribute to query. params is the form’s params.

returns an Array ‘plucked’ from the results

this method is usually called internally, from javascript



33
34
35
# File 'lib/filch.rb', line 33

def self.datalist(model_name, attr, params)
  Datalist.quick(model(model_name), attr, params)
end

.model(model_find = nil) ⇒ Object

model_find should be a String representing the name of a model. returns a model. If model_find is nil, or the model is not found, return the first model.



48
49
50
# File 'lib/filch.rb', line 48

def self.model(model_find = nil)
  ModelFind.find(model_find)
end

.ransack_plus(params, query) ⇒ Object

Filch::RansackPlus. recieves the form params<i>, for the ‘plus’ methods <i>q is the form object. returns an array of ransacked results



41
42
43
# File 'lib/filch.rb', line 41

def self.ransack_plus(params, query)
  RansackPlus.new(params, query)
end

.templates(model) ⇒ Object



21
22
23
# File 'lib/filch.rb', line 21

def self.templates(model)
  Templates.new(model)
end