From 45b6ff53f176f46f8d768773cbe93fc2f6c93dca Mon Sep 17 00:00:00 2001 From: Aria Stewart Date: Sat, 18 Sep 2010 16:35:48 -0600 Subject: [PATCH] Ruby 1.9 fixes --- app/controllers/photos_controller.rb | 4 ++-- app/models/photo.rb | 2 +- config.ru | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index cefc8f5d6..4065ff34c 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -21,9 +21,9 @@ class PhotosController < ApplicationController # get file content type att_content_type = (request.content_type.to_s == "") ? "application/octet-stream" : request.content_type.to_s # create temporal file - file = Tempfile.new(file_name) + file = Tempfile.new(file_name, {encoding: 'BINARY'}) # put data into this file from raw post request - file.print request.raw_post + file.print request.raw_post.force_encoding('BINARY') # create several required methods for this temporal file Tempfile.send(:define_method, "content_type") {return att_content_type} diff --git a/app/models/photo.rb b/app/models/photo.rb index 8792911f3..92b02d36d 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -22,7 +22,7 @@ class Photo < Post timestamps! validates_presence_of :album - validates_true_for :album_id, :logic => lambda {self.validate_album_person} + validates_true_for(:album_id, :logic => Proc.new { self.validate_album_person }) before_destroy :ensure_user_picture diff --git a/config.ru b/config.ru index cb12bcfa2..ed9da1085 100644 --- a/config.ru +++ b/config.ru @@ -6,6 +6,7 @@ # This file is used by Rack-based servers to start the application. +$LOAD_PATH << '.' require ::File.expand_path('../config/environment', __FILE__) #use Rack::FiberPool #require 'lib/chrome_frame'