2

I'm using MongoMapper with Joint on Padrino, and trying to get the upload working. However, I keep getting thrown a NoMethodError "undefined method 'path' for #<Hash:0xa6fbdf0>". It seems like it can't see the path, but the parameters are okay. What is the problem here?

Gist with the code: https://gist.github.com/1323998

I was able to get it to not error, but when I go to find the file with mongofiles, I can't find. The same goes for rack/grid-fs. Where is Joint saving to, and is it saving at all?

Ethan Turkeltaub
  • 2,931
  • 8
  • 30
  • 45
  • Where is that error coming from? I don't see any mention of "path" in any of that code. – mu is too short Oct 29 '11 at 02:35
  • Joint automatically adds the `path` field into my model when I specify `attachment :file`. I assume it's trying to use that but can't. – Ethan Turkeltaub Oct 29 '11 at 02:57
  • But someone is trying to call `path` on a Hash so you need to know where the error is coming from so you can backtrack and find out why you have a Hash when someone is expecting an instance of your model. – mu is too short Oct 29 '11 at 03:09
  • Done. Looks to be a MM issue. – Ethan Turkeltaub Oct 29 '11 at 18:41
  • Looks like it is getting called here https://github.com/jnunemaker/joint/blob/master/lib/joint.rb#L18 – ToreyHeinz Sep 21 '12 at 13:12
  • I think is an issue with how how Padrino handles attachement uploads in Rails when you upload a file you get a ActionDispatch::Http::UploadedFile object, that repsonds_to original_filename. – ToreyHeinz Sep 21 '12 at 13:15

1 Answers1

1

See my comments above:

Here's my thought on what you need to do, I think you need to modify the params so that params[:background][:file] is the tempfile object, like so:

params[:background][:file] = params[:background][:file][:tempfile]
background = Background.create(params[:background])

I'm not 100% sure on this, but if this doen't work I could setup a quick Padrino app and test.

ToreyHeinz
  • 585
  • 1
  • 4
  • 16