Before updating my Macbook I used Ruby 1.8.7 and Rails 3.0.9 my app worked very nice.
UPD: actually the problem was different, see the answer below.
Now I have the same Rails (as it is in Gemfile) but Ruby Version is 1.9.2, and I have some problems with it. So the one of them is that I’ve lost the ability to upload files through valums AJAX uploader and rawfileupload. It seems clear, all the data is passed through:
{"photo"=>{
"image"=>#<ActionDispatch::Http::UploadedFile:0x007fd47fe5df20
@original_filename="appleberry.jpg", @content_type="image/jpeg", @headers=nil,
@tempfile=#<File:blah-blah a real file, i can see it>},
"album_id"=>"6",
"authenticity_token"=>"<is ok>=", "qqfile"=>"appleberry.jpg"
}
But then I get the following SQL insert:
INSERT INTO "photos" (
"name", "description",
"created_at", "updated_at",
"album_id", "image_file_name",
"image_content_type", "image_file_size",
"image_updated_at", "created_by")
VALUES (NULL, NULL,
'2011-10-23 19:08:18.746030', '2011-10-23 19:08:18.746030',
6, NULL,
NULL, NULL,
NULL, NULL)
It can`t be a controller, because it`s supersimple
@photo = Photo.new(params[:image])
@photo.album_id = params[:album_id]
if @photo.save
...
That’s a nasty problem, I tried even to downgrade to ruby 1.8.7, since I’m using rvm, but I haven’t got it yet. If the best way is using 1.8.7 I’ll do so, but, please, tell my how =)
Thanks!
It was my mistake, as I found out. In rails I had a wrong declaration of Photo.new(), I used
params[:image]but it should have beenparams[:photo]. And that`s why I got a lot ofNULLsin a query.Just keep it in mind next time, saving images