carrierwave support
darkleaf opened this issue · 9 comments
darkleaf commented
class Person < ActiveRecord::Base
mount_uploader :photo, PersonUploader #iphoto of type string in db
end
...
@attrs = attributes_for :person #FactoryGirl
puts @attrs[:photo] #=> #<Rack::Test::UploadedFile:0x00000005a73c30>
puts @attrs[:photo].length #=> 9759
I have validtion error because 9759 > string length(255).
akirill0v commented
@darkleaf Rack::Test::UploadedFile only in the TEST environment?
Which values in other environments? Successful validation in them?
melekes commented
@saratovsource this fails both on production and testing. I think we have to add skip_autovalidation_on
option to handle such cases.
Eg:
class Course < AR::Base
skip_autovalidation_on :image
end
darkleaf commented
@akalyaev, I have not found such a method.
darkleaf commented
@akalyaev, I think that this method should have another name.
May be skip_valle_validation :image
?
melekes commented
melekes commented
@darkleaf Now you can use attributes
option to skip adding validation to photo
field:
Valle.configure do |config|
config.attributes = {
'Person' => %w(id <other_attributes_except_photo>)
}
end
darkleaf commented
May be easier to test class of field?
It skip validation if class isn't String.