Skip to content

Instantly share code, notes, and snippets.

@LucasKuhn
Created July 17, 2020 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LucasKuhn/158fa37aecbc725ed33c9b4d6fd34481 to your computer and use it in GitHub Desktop.
Save LucasKuhn/158fa37aecbc725ed33c9b4d6fd34481 to your computer and use it in GitHub Desktop.
What form_with does
# helpers/form_helper.rb
def form_with(model: nil, scope: nil, url: nil)
# ...
url = polymorphic_path(model)
html_options = html_options_for_form_with(url, model, **options)
form_tag_html(html_options)
end
# helpers/form_tag_helper.rb
def form_tag_html(html_options)
# ...
tag(:form, html_options, true)
end
# helpers/tag_helper.rb
def tag(name = nil, options = nil)
# ...
"<#{name}#{tag_builder.tag_options(options, escape) if options}#{open ? ">" : " />"}".html_safe
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment