Created
March 20, 2012 19:19
-
-
Save necocen/2140108 to your computer and use it in GitHub Desktop.
http://twitter.com/#!/necocen/status/182161794570260481 これをなんとかするコード(インデントはスペース二個、タブの場合はいくらか変更が必要)。RAILS_ROOT/config/initializersに置くと動く。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActionView::Helpers::FormTagHelper | |
def extra_tags_for_form(html_options) | |
authenticity_token = html_options.delete("authenticity_token") | |
method = html_options.delete("method").to_s | |
method_tag = case method | |
when /^get$/ | |
html_options["method"] = "get" | |
'' | |
when /^post$/, "", nil | |
html_options["method"] = "post" | |
((authenticity_token == false || !protect_against_forgery?) ? "" : "\n ") << token_tag(authenticity_token) | |
else | |
html_options["method"] = "post" | |
"\n " << tag(:input, :type => "hidden", :name => "_method", :value => method) | |
end | |
tags = "\n " << utf8_enforcer_tag << method_tag << "\n " | |
" " << content_tag(:div, tags, {:style => 'margin:0;padding:0;display:inline;'}, false) | |
end | |
def form_tag_html(html_options) | |
extra_tags = extra_tags_for_form(html_options).html_safe | |
(tag(:form, html_options, true) + "\n" + extra_tags).html_safe | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment