Hi,
I have this small problem that made me really frustrating for 3 hours.
the code is simple. Im using rails 3.1. it uses paperclip gem to
manage attachment. this code works fine on production and development
either
with mri 1.9.2 or ree 1.8.7, the problem is when i test it using
cucumber
here is the code
def create
@photo = Photo.new(params[:photo])
@photo.md5sum = @photo.file.fingerprint
@duplicate = Photo.find_by_md5sum(@photo.md5sum)
@test = Photo.all
if @duplicate
flash[:error] = “Found duplicate entry”
else
@result = @photo.save
end
end
it just check for the md5sum of the photo, and save if it’s not
duplicate.
i test it using cucumber, the problem is with Photo.find_by_md5sum. it
return nil. but the @test return all of the record, including the record
with the md5sum that should be matched.
i also try to changed it with Photo.where(:md5sum => @photo.md5sum) but
on
1.9.2 its return to [].
but funny, when I change it using like cause, Photo.where(“md5sum like
?”,
@photo.md5sum) it return the right object.
the only problem if i try to use equality in the query. it always
returns
nil on 1.9.2. when i test it using ree 1.8.2 everything works fine.
I have no idea how this happend, maybe some one here face the same
problem ?