1. You should speficy the exact ruby version you want to run in your Gemfile:
ruby '2.0.0'
2. add to Gemfile:
gem 'rails_12factor', group: :production
3.When deploying to Heroku by default Rails will attempt to intialize itself before the assets are precompiled. This step will fail because the application will attempt to establish a database connection, which Heroku will not have set up yet.
To work around this issue, put this line underneath the other config.assets lines inside config/application.rb:
config.assets.initialize_on_precompile = false
The assets for your application will still be precompiled, it’s just that Rails won’t be intialized during this process.
4. To configure Spree to upload images to S3, put these lines into config/initializers/spree.rb:
Spree.config do |config|
config.use_s3 = true
config.s3_bucket = '<bucket>'
config.s3_access_key = "<key>"
config.s3_secret = "<secret>"
end
And additionally you will need to tell paperclip how to construct the URLs for your images by placing this code outside the +config+ block inside config/initializers/spree.rb:
Paperclip.interpolates(:s3_eu_url) do |attachment, style|
"#{attachment.s3_protocol}://#{Spree::Config[:s3_host_alias]}/#{attachment.bucket_name}/#{attachment.path(style).gsub(%r{^/},"")}"
end
PUSHING TO HEROKU
1. Run on terminal:
ruby '2.0.0'
2. add to Gemfile:
gem 'rails_12factor', group: :production
3.When deploying to Heroku by default Rails will attempt to intialize itself before the assets are precompiled. This step will fail because the application will attempt to establish a database connection, which Heroku will not have set up yet.
To work around this issue, put this line underneath the other config.assets lines inside config/application.rb:
config.assets.initialize_on_precompile = false
The assets for your application will still be precompiled, it’s just that Rails won’t be intialized during this process.
4. To configure Spree to upload images to S3, put these lines into config/initializers/spree.rb:
Spree.config do |config|
config.use_s3 = true
config.s3_bucket = '<bucket>'
config.s3_access_key = "<key>"
config.s3_secret = "<secret>"
end
And additionally you will need to tell paperclip how to construct the URLs for your images by placing this code outside the +config+ block inside config/initializers/spree.rb:
Paperclip.interpolates(:s3_eu_url) do |attachment, style|
"#{attachment.s3_protocol}://#{Spree::Config[:s3_host_alias]}/#{attachment.bucket_name}/#{attachment.path(style).gsub(%r{^/},"")}"
end
PUSHING TO HEROKU
1. Run on terminal:
$ cd myapp $ git init Initialized empty Git repository in .git/ $ git add . $ git commit -m "my first commit" Created initial commit 5df2d09: my first commit 44 files changed, 8393 insertions(+), 0 deletions(-) create mode 100644 README create mode 100644 Procfile create mode 100644 app/controllers/source_file ...2.$ heroku create
Creating falling-wind-1624... done, stack is cedar http://falling-wind-1624.herokuapp.com/ | git@heroku.com:falling-wind-1624.git Git remote heroku added3.
$ git remote -v heroku git@heroku.com:falling-wind-1624.git (fetch)
heroku git@heroku.com:falling-wind-1624.git (push)4. Deploying
$ git push heroku master Initializing repository, done. updating 'refs/heads/master' ...A common key error is:
Permission denied (publickey).You can fix this by using keys:add to notify Heroku of your new key.$ heroku keys:add Found existing public key: /Users/adam/.ssh/id_rsa.pub Uploading SSH public key /Users/adam/.ssh/id_rsa.pub... done
Comments
Post a Comment