Can you remove _snowman in Rails 3?

I am building an application on Rails 3 RC. I understand the point behind the _snowman parameter ( http://railssnowman.info/)...however , I have a search form that makes a GET request to the index. the form creates the following query line:

?

_ snowman = β˜ƒ & search = Box

I do not know that UTF encoding support is as important as the query string line for this particular form. (Maybe I'm just too perfectionist ... hehe) Is there a way to remove the _snowman parameter only for this form? I would prefer not to convert the form to a POST request to hide the snowman, but I would also prefer it not to be in my request line. Any thoughts?

+4
source share
3 answers

You can avoid the snowman (now checkmark) in Rails 3 ... without using Rails for the search form. Instead of using form_tag, write your own as indicated in: Rails 3 UTF-8 query string displayed in url?

Rails helpers are great if they don't help. Do-it-yourself is good as long as you understand the implications and is ready to support it in the future.

+1
source

I believe that the snowman should be sent by wire to ensure that your data is encoded correctly, which means that you cannot remove the snowman’s input from the forms. Since it is sent to your GET request, it must be added to the URL.

I suppose you could write javascript to clear the url after loading the search page, or you can set the redirect to the equivalent url minus the snowman. I don’t really like both options.

Also, there seems to be no way to configure Rails so that it does not display it. If you really want to get rid of it, you can comment on these lines in the Rails source (patched patches at the bottom of railssnowman.info should lead you to files and line numbers). This adds some repair work for you when upgrading Rails. Perhaps you can send a patch to disable it?

EDIT: Looks like they just switched it to what looks like a checkmark instead of a snowman .

EDIT: Oh, go back to the snowman .

0
source

In Rails 4.1, you can use the option :enforce_utf8 => false to disable the utf8 input tag.

However, I want to use this in Rails 3, so I defused my Rails. I put the following in the config / initializers directory.

 # allow removing utf8 using enforce_utf8, remove after Rails 4.1 module ActionView module Helpers module 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$/i # must be case-insensitive, but can't use downcase as might be nil html_options["method"] = "get" '' when /^post$/i, "", nil html_options["method"] = "post" token_tag(authenticity_token) else html_options["method"] = "post" tag(:input, :type => "hidden", :name => "_method", :value => method) + token_tag(authenticity_token) end enforce_utf8 = html_options.delete("enforce_utf8") { true } tags = (enforce_utf8 ? utf8_enforcer_tag : ''.html_safe) << method_tag content_tag(:div, tags, :style => 'margin:0;padding:0;display:inline') end end end end 
0
source

All Articles