A
A
alexnotonfire2016-02-05 02:17:20
Ruby on Rails
alexnotonfire, 2016-02-05 02:17:20

How to display validation error message for Carrierwave bootloader?

I'm trying to make sure every object has an attached picture when it's created. At the moment I'm running into an issue where I just can't seem to get an error message to be displayed when a picture hasn't been attached. The error simply does not appear on the form, while all other validations are displayed. How can I fix this?
article.rb

class Article < ActiveRecord::Base
  validates :picture, presence: true
  mount_uploader :picture, ImageUploader
end

= simple_form_for article, remote: true do |f|
  = f.hidden_field(:picture_cache)
  = f.file_field(:picture)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vsuhachev, 2016-02-05
@alexnotonfire

First, make sure that there really is an error, for this, print out article.errors.messages
Second, look at how simple_form renders file_field, maybe there is some kind of invisible input that the error clings to

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question