1
我故意上傳一個非圖像文件通過張貼到iframe(假的Ajax),但我沒有得到Flash錯誤。回形針驗證錯誤不閃爍
我的更新動作:
def update
@mockup = Mockup.find_by_hash_id(params[:hash_id])
@mockup.update_attributes(params[:mockup])
flash[:notice] = 'Mockup updated'
redirect_to new_or_show_mockup_path(@mockup.hash_id)
rescue Exception => e
flash[:error] = e.message
redirect_to new_or_show_mockup_path(@mockup.hash_id)
end
我的模型:
class Mockup < ActiveRecord::Base
validates_attachment_content_type :image, :content_type => ['image/jpeg', 'image/jpg', 'image/png'], :message => 'Please upload an image'
end