Class: AwesomeForm::FormBuilder
Instance Method Summary
collapse
#action_label, #input_label
#association_name, #collection_name, #input_id, #input_name
#render_method
#discover_attributes
Constructor Details
Returns a new instance of FormBuilder.
15
16
17
|
# File 'lib/awesome_form/form_builder.rb', line 15
def initialize(*)
super
end
|
Instance Method Details
#filter_attributes_for(html, options) ⇒ Object
35
36
37
38
39
40
|
# File 'lib/awesome_form/form_builder.rb', line 35
def filter_attributes_for(html, options)
options.select do |k|
AwesomeForm.legal_attributes[html].include?(k) ||
k.to_s =~ /^data($|-)/
end
end
|
#lookup_views(paths) ⇒ Object
31
32
33
|
# File 'lib/awesome_form/form_builder.rb', line 31
def lookup_views(paths)
paths.select { |p| view_exists? p }.first
end
|
#model_name ⇒ Object
42
43
44
|
# File 'lib/awesome_form/form_builder.rb', line 42
def model_name
object.class.name.underscore
end
|
#render(render_options) ⇒ Object
19
20
21
|
# File 'lib/awesome_form/form_builder.rb', line 19
def render(render_options)
@template.render(render_options)
end
|
#resource_name ⇒ Object
46
47
48
|
# File 'lib/awesome_form/form_builder.rb', line 46
def resource_name
model_name.pluralize
end
|
#view_exists?(view) ⇒ Boolean
23
24
25
26
27
28
29
|
# File 'lib/awesome_form/form_builder.rb', line 23
def view_exists?(view)
path_elements = view.split('/')
view = "_#{path_elements.pop}".squeeze '_'
prefix = path_elements.join('/')
@template.lookup_context.exists? view, [prefix]
end
|