Hello! I’m using Rails 3, Uploadify, to send images to S3.
Right now all the images being uploaded to S3 have the MIME:
application/octet-stream
I’d like to fix that but I’m getting the following error:
NoMethodError (undefined method `original_filename' for
#ActiveSupport::HashWithIndifferentAccess:0x107c81998):
app/models/photo.rb:29:in upload_file=' app/controllers/photos_controller.rb:15:in
upload’
app/middleware/flash_session_cookie_middleware.rb:14:in `call’
I think this is because all the tutorials out there aren’t Rails 3
friendly. Anyone have any ideas? Here’s the code:
# Controller
def create
@photo = @photoalbum.photos.build(:upload_file => params[:photo])
...
end
# Model
class Photo < ActiveRecord::Base
require 'mime/types'
...
def upload_file=(data)
data.content_type =
MIME::Types.type_for(data.original_filename).to_s
self.image = data
end
end