Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

carrierwave support #4

Closed
darkleaf opened this issue Apr 23, 2013 · 9 comments
Closed

carrierwave support #4

darkleaf opened this issue Apr 23, 2013 · 9 comments
Labels
Milestone

Comments

@darkleaf
Copy link

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).

@ghost ghost assigned melekes Nov 8, 2013
@akirill0v
Copy link
Contributor

@darkleaf Rack::Test::UploadedFile only in the TEST environment?
Which values ​​in other environments? Successful validation in them?

@melekes
Copy link
Owner

melekes commented Nov 14, 2013

@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
Copy link
Author

@akalyaev, I have not found such a method.

@melekes
Copy link
Owner

melekes commented Nov 15, 2013

@darkleaf It will be, soon 😄

@darkleaf
Copy link
Author

@akalyaev, I think that this method should have another name.
May be skip_valle_validation :image?

@melekes
Copy link
Owner

melekes commented Nov 15, 2013

@darkleaf Why do you think so? skip_autovalidation_on clearly indicates what it does. I consider the addition of valle prefix not necessarily here.

/cc @saratovsource @qblake What do you think?

@melekes
Copy link
Owner

melekes commented Nov 15, 2013

@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
Copy link
Author

May be easier to test class of field?
It skip validation if class isn't String.

@melekes
Copy link
Owner

melekes commented Nov 15, 2013

@darkleaf see README for details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants