Domanda

Questo dovrebbe essere un compito facile, ma ho appena cant trovare la risposta! Le mie forme ferroviario generano un div che voglio sbarazzarsi di

Questo è il div che generano rotaie per me

   <div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713"/><input name="authenticity_token" type="hidden" value="Z6UAdFYt3v8d1lx4BNXq5td3OMJ223i+ruKM8Ldb+5s=" /></div>

Ho dato un'occhiata ad alcune domande anteprime che sono state suggerendo dovrei usare form_authenticity_token

Dove e come nel codice Posso usare form_authenticity_token invece?

È stato utile?

Soluzione

Quale versione di Rails stai usando?

Non so perché si vuole fare questo. Se si tratta di un problema di CSS si può solo essere più specifico. Non ho mai avuto bisogno di fare questo. Tuttavia ...

Il modo per farlo in 3.0.9 sarebbe fare un inizializzatore e aggiungendo questo codice:

module ActionView
  module Helpers
    module FormHelper
        def extra_tags_for_form(html_options)
          snowman_tag = tag(:input, :type => "hidden",
                            :name => "utf8", :value => "&#x2713;".html_safe)

          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
            else
              html_options["method"] = "post"
              tag(:input, :type => "hidden", :name => "_method", :value => method) + token_tag
          end

          tags = snowman_tag << method_tag
          content_tag(:span, tags, :style => 'margin:0;padding:0;display:inline')
        end
  end
end
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top