Module: Kilt::Form
- Defined in:
- lib/kilt/form.rb
Constant Summary collapse
- TEMPLATES_DIR =
if ENV['RAILS_ENV'] == 'test' '/' else "#{Kilt::Engine.root}/app/views/kilt/form" end
Class Method Summary collapse
Class Method Details
.method_missing(method, *args) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/kilt/form.rb', line 10 def self.method_missing(method, *args) locals = { object: args[0], field_name: args[1], index: args[2], options: args[3] } render_view method, locals rescue render_view '_default', locals end |
.prep_field(method, *args) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kilt/form.rb', line 17 def self.prep_field(method, *args) # This is a method called before the generic method_missing. # In this method, we'll parse out the method value to see if there are # any options being passed in with the name of the field. # Example: select(small|large) if (method.include? "(") && (method.include? ")") first_split = method.split("(") method_name = first_split.first # Now get the option values and push them onto the arg stack second_split = first_split[1].split(")") = second_split.first if args << end else method_name = method end self.send(method_name.strip, *args) end |