views:

10

answers:

0

I am using PaperClip in one of my Rails applications. I notice that validation works as expected, but the label of the rendered file attachment does not get red. I checked the rendered HTML and the class required to make the label red does not go there.

Here is my code:

<div class="field">
  <%= f.label :photo %>
  <br/>
  <%= f.file_field :photo %>
</div>
<div class="field">
  <%= f.label :details %>
  <br/>
  <%= f.text_area :details %>
</div>

My validation:

validates :category, :subcategory, :details, :presence => true
validates_attachment_presence :photo
validates_attachment_size :photo, :less_than=>1.megabyte

When I submit the form, here is the rendered HTML:

<div class="field">    
<label for="ad_photo">Photo</label>
<br/>
<input id="ad_photo" name="ad[photo]" type="file" />
</div>
<div class="field">
<div class="field_with_errors"><label for="ad_details">Details</label></div>
<br/>
<div class="field_with_errors"><textarea cols="40" id="ad_details" name="ad[details]" rows="20"></textarea></div>
</div>

Observe that in the second label and control, there is the class "field_with_errors". Any one know why the file upload label and control do not have this css class?