Module: Detour::ApplicationHelper
- Defined in:
- app/helpers/detour/application_helper.rb
Instance Method Summary collapse
- #link_to_add_fields(name, f, association, template = nil) ⇒ Object
- #modal(options, &block) ⇒ Object
- #modal_footer(&block) ⇒ Object
- #table(&block) ⇒ Object
Instance Method Details
#link_to_add_fields(name, f, association, template = nil) ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'app/helpers/detour/application_helper.rb', line 2 def link_to_add_fields(name, f, association, template = nil) new_object = f.object.send(association).klass.new template ||= "#{association.to_s.singularize}_fields" id = new_object.object_id fields = f.fields_for(association, new_object, child_index: id) do |builder| render("#{template}", f: builder) end link_to name, "javascript:void(0)", class: "add-fields btn btn-default", data: { id: id, fields: fields.gsub("\n", "") } end |
#modal(options, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/helpers/detour/application_helper.rb', line 21 def modal(, &block) content_tag :div, id: [:id], class: "modal #{[:fade].present?}", tabindex: "-1", role: "dialog", aria_labbeledby: "#{[:id]}-modal-label", aria_hidden: "true" do content_tag :div, class: "modal-dialog" do content_tag :div, class: "modal-content" do content_tag(:div, class: "modal-header") do content_tag :button, "×", class: "close", data_dismiss: "modal", aria_hidden: "true" content_tag :h4, [:title], id: "#{[:id]}-modal-label" end + content_tag(:div, class: "modal-body") do yield end end end end end |
#modal_footer(&block) ⇒ Object
38 39 40 41 42 |
# File 'app/helpers/detour/application_helper.rb', line 38 def (&block) content_tag :div, class: "modal-footer" do yield end end |
#table(&block) ⇒ Object
13 14 15 16 17 18 19 |
# File 'app/helpers/detour/application_helper.rb', line 13 def table(&block) content_tag :div, class: "table-responsive" do content_tag :table, class: "table table-striped" do yield end end end |