Note that there are some explanatory texts on larger screens.

plurals
  1. POChanging error display format in Rails ActionView Helpers
    primarykey
    data
    text
    <p>I'm trying to modify the default behaviour of showing errors before the form to show them next to the fields instead.</p> <p>I'm using this to achieve that:</p> <pre><code> ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| if instance.error_message.kind_of?(Array) %(#{html_tag}&lt;span class="validation-error"&gt;&amp;nbsp; #{instance.error_message.join(',')}&lt;/span&gt;) else %(#{html_tag}&lt;span class="validation-error"&gt;&amp;nbsp; #{instance.error_message}&lt;/span&gt;) end end </code></pre> <p>However, for some reason, the result html is coded with entities, so it doesn't get displayed:</p> <pre><code>&lt;div class="group"&gt; &lt;label class="label" for="user_city"&gt;City and Postcode&lt;/label&gt; &lt;input class="text_field" id="user_city" name="user[city]" size="30" type="text" value="94-050 Łódź" /&gt; &lt;span class="description"&gt;np. 00-000 Łódź&lt;/span&gt; &lt;/div&gt; &lt;div class="group"&gt; &amp;lt;label class=&amp;quot;label&amp;quot; for=&amp;quot;user_street&amp;quot;&amp;gt;Address&amp;lt;/label&amp;gt;&amp;lt;span class=&amp;quot;validation-error&amp;quot;&amp;gt;&amp;amp;nbsp; translation missing: pl, activerecord, errors, models, user, attributes, street, blank&amp;lt;/span&amp;gt; &amp;lt;input class=&amp;quot;text_field&amp;quot; id=&amp;quot;user_street&amp;quot; name=&amp;quot;user[street]&amp;quot; size=&amp;quot;30&amp;quot; type=&amp;quot;text&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;span class=&amp;quot;validation-error&amp;quot;&amp;gt;&amp;amp;nbsp; translation missing: pl, activerecord, errors, models, user, attributes, street, blank&amp;lt;/span&amp;gt; &lt;span class="description"&gt; &amp;nbsp;&lt;/span&gt; &lt;/div&gt; </code></pre> <p>How can I avoid the result being html_entitied?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload