I use carrierwave gem for uploading image.I use attr_accessor: avatar in my model.I don't want to create the database column. I can store avatar in the particular directory.But when i update_attribute for some other field, i am getting undefined method undefined method
avatar_changed?' for User`. Am i missing anything here? Help me to solve this.
This is my User model
attr_accessor: avatar
mount_uploader: avatar, AvatarUploader
AvatarUploader < IconBase
DIEMENSIONS=[120,120]
def filename
"avatar.png"
end
end
If you use
mount_uploader: avatar, AvatarUploader
you should create database columns. IF you do not want to add columns, you should not mount an Uploader, but rather work with things like that:
uploader = AvatarUploader.new
uploader.store!(my_file)
uploader.retrieve_from_store!('my_file.png')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With