how to prevent a newline after a button_to

This is something that gets tossed around from time to time. The official (barely) agreed upon stance is:

"The div is for HTML4.01/XHTML1.0 strict compliance. An input can only be contained by one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins" or "del". " [ http://dev.rubyonrails.org/ticket/10422 ]

But this annoys me too. There are a few ways of handling this. button_to creates a form tag with a class of "button_to". So in your stylesheet, you should be able to do something with .button_to .form .div and remove the spacing. (I haven't tried this myself yet, and I'm not a css whiz, so YMMV).

If you care less about strict compliance, and want to get rid of the div tags totally, then the following in you application.rb will work:

module Helpers     module UrlHelper       def button_to(name, options = {}, html_options = nil)

        html_options = (html_options || {}).stringify_keys         convert_boolean_attributes!(html_options, %w( disabled ))

        if confirm = html_options.delete("confirm")           html_options["onclick"] = "return # {confirm_javascript_function(confirm)};"         end         options = {:only_path=>false}.update(options)         url = options.is_a?(String) ? options : url_for(options)         name ||= url

        html_options.symbolize_keys!         tag(:input, html_options.merge({           :type => "button", :value => name,           :onclick => (html_options[:onclick] ? "#{html_options [:onclick]}; " : "") + "window.location.href='#{url_for(options)}';"         }))

      end     end   end