Fix Heroku deployment

This commit is contained in:
wvengen 2016-05-25 02:05:55 +02:00
parent be287cf67e
commit f08d131842
2 changed files with 5 additions and 4 deletions

View file

@ -1,5 +1,3 @@
require 'filemagic'
class Invoice < ActiveRecord::Base class Invoice < ActiveRecord::Base
belongs_to :supplier belongs_to :supplier
@ -20,7 +18,8 @@ class Invoice < ActiveRecord::Base
def attachment=(incoming_file) def attachment=(incoming_file)
self.attachment_data = incoming_file.read self.attachment_data = incoming_file.read
self.attachment_mime = FileMagic.new(FileMagic::MAGIC_MIME).buffer(self.attachment_data) # allow to soft-fail when FileMagic isn't present and removed from Gemfile (e.g. Heroku)
self.attachment_mime = defined?(FileMagic) ? FileMagic.new(FileMagic::MAGIC_MIME).buffer(self.attachment_data) : 'application/octet-stream'
end end
def delete_attachment=(value) def delete_attachment=(value)

View file

@ -51,9 +51,11 @@ if ! git checkout -b "$BRANCH"; then
echo "Could not create to temporary branch '$BRANCH', aborting." 1>&2 echo "Could not create to temporary branch '$BRANCH', aborting." 1>&2
exit 1 exit 1
fi fi
# remove sqlite3 dependency as it doesn't install on heroku # remove sqlite3 + filemagic dependency as they don't install on heroku
sed -i "s|^\\(\\s*gem\\s\\+'sqlite3'\\)|#\1|" Gemfile sed -i "s|^\\(\\s*gem\\s\\+'sqlite3'\\)|#\1|" Gemfile
sed -i "s|^\\(\\s*sqlite3\\b\)|#\1|" Gemfile.lock sed -i "s|^\\(\\s*sqlite3\\b\)|#\1|" Gemfile.lock
sed -i "s|^\\(\\s*gem\\s\\+'ruby-filemagic'\\)|#\1|" Gemfile
sed -i "s|^\\(\\s*ruby-filemagic\\b\)|#\1|" Gemfile.lock
# make sure postgresql db is present, as it is the default heroku db # make sure postgresql db is present, as it is the default heroku db
echo " echo "
gem 'rails_12factor' gem 'rails_12factor'