Errors when deploying Rails App to Heroku - ruby-on-rails

Hello I am just starting to learn Ruby on Rails and am watching the Railstutoprials screen casts. However When I do my git push to heroku and try to load my rails app I get an error and my logs look like this.
2013-06-26T22:41:06.427464+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 55907 -e $RAILS_ENV`
2013-06-26T22:41:07.770202+00:00 app[web.1]:
2013-06-26T22:41:07.770515+00:00 app[web.1]: Options:
2013-06-26T22:41:07.770114+00:00 app[web.1]: rails new APP_PATH [options]
2013-06-26T22:41:07.771778+00:00 app[web.1]: -m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL)
2013-06-26T22:41:07.771778+00:00 app[web.1]: -r, [--ruby=PATH] # Path to the Ruby binary of your choice
2013-06-26T22:41:07.771778+00:00 app[web.1]: -B, [--skip-bundle] # Don't run bundle install
2013-06-26T22:41:07.770029+00:00 app[web.1]: Usage:
2013-06-26T22:41:07.771962+00:00 app[web.1]: # Default: sqlite3
2013-06-26T22:41:07.771778+00:00 app[web.1]: -d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
2013-06-26T22:41:07.771962+00:00 app[web.1]: -j, [--javascript=JAVASCRIPT] # Preconfigure for selected JavaScript library
2013-06-26T22:41:07.771778+00:00 app[web.1]: # Default: /app/vendor/ruby-2.0.0/bin/ruby
2013-06-26T22:41:07.771778+00:00 app[web.1]: [--skip-gemfile] # Don't create a Gemfile
2013-06-26T22:41:07.771778+00:00 app[web.1]: -O, [--skip-active-record] # Skip Active Record files
2013-06-26T22:41:07.771778+00:00 app[web.1]: -G, [--skip-git] # Skip .gitignore file
2013-06-26T22:41:07.771962+00:00 app[web.1]: -J, [--skip-javascript] # Skip JavaScript files
2013-06-26T22:41:07.771778+00:00 app[web.1]: [--skip-keeps] # Skip source control .keep files
2013-06-26T22:41:07.771778+00:00 app[web.1]: -S, [--skip-sprockets] # Skip Sprockets files
2013-06-26T22:41:07.771962+00:00 app[web.1]: # Default: jquery
2013-06-26T22:41:07.771962+00:00 app[web.1]: [--edge] # Setup the application with Gemfile pointing to Rails repository
2013-06-26T22:41:07.771962+00:00 app[web.1]: -T, [--skip-test-unit] # Skip Test::Unit files
2013-06-26T22:41:07.771962+00:00 app[web.1]: [--rc=RC] # Path to file containing extra configuration options for rails command
2013-06-26T22:41:07.771962+00:00 app[web.1]: [--dev] # Setup the application with Gemfile pointing to your Rails checkout
2013-06-26T22:41:07.771962+00:00 app[web.1]: [--no-rc] # Skip loading of extra configuration options from .railsrc file
2013-06-26T22:41:07.771962+00:00 app[web.1]:
2013-06-26T22:41:07.772167+00:00 app[web.1]: Runtime options:
2013-06-26T22:41:07.772167+00:00 app[web.1]: -f, [--force] # Overwrite files that already exist
2013-06-26T22:41:07.772167+00:00 app[web.1]: -p, [--pretend] # Run but do not make any changes
2013-06-26T22:41:07.773137+00:00 app[web.1]: Rails options:
2013-06-26T22:41:07.772167+00:00 app[web.1]: -s, [--skip] # Skip files that already exist
2013-06-26T22:41:07.772167+00:00 app[web.1]: -q, [--quiet] # Suppress status output
2013-06-26T22:41:07.772167+00:00 app[web.1]:
2013-06-26T22:41:07.773756+00:00 app[web.1]: Description:
2013-06-26T22:41:07.773217+00:00 app[web.1]: -v, [--version] # Show Rails version number and quit
2013-06-26T22:41:07.773756+00:00 app[web.1]: The 'rails new' command creates a new Rails application with a default
2013-06-26T22:41:07.773217+00:00 app[web.1]: -h, [--help] # Show this help message and quit
2013-06-26T22:41:07.773756+00:00 app[web.1]: directory structure and configuration at the path you specify.
2013-06-26T22:41:07.773756+00:00 app[web.1]: 'rails new' runs in the .railsrc configuration file in your home directory.
2013-06-26T22:41:07.773217+00:00 app[web.1]:
2013-06-26T22:41:07.773756+00:00 app[web.1]: defaults values shown above in this help message.
2013-06-26T22:41:07.773756+00:00 app[web.1]:
2013-06-26T22:41:07.773756+00:00 app[web.1]: You can specify extra command-line arguments to be used every time
2013-06-26T22:41:07.773756+00:00 app[web.1]: Note that the arguments specified in the .railsrc file don't affect the
2013-06-26T22:41:07.773756+00:00 app[web.1]:
2013-06-26T22:41:07.773756+00:00 app[web.1]:
2013-06-26T22:41:07.773989+00:00 app[web.1]: Example:
2013-06-26T22:41:07.773989+00:00 app[web.1]:
2013-06-26T22:41:07.773989+00:00 app[web.1]: See the README in the newly created application to get going.
2013-06-26T22:41:07.773989+00:00 app[web.1]: rails new ~/Code/Ruby/weblog
2013-06-26T22:41:07.773989+00:00 app[web.1]: This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
2013-06-26T22:41:09.160872+00:00 heroku[web.1]: Process exited with status 0
2013-06-26T22:41:09.172961+00:00 heroku[web.1]: State changed from starting to crashed
My Gemfile looks like:
source 'https://rubygems.org'
ruby '2.0.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
# Use postgresql as the database for Active Record
gem 'pg', group: :production
gem 'sqlite3', group: [:test, :development]
# Use V8 JavaScript engine
gem 'therubyracer'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
gem 'rails_12factor'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
and finally my database.yml
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: postgresql
database: social_pantry
pool: 5
timeout: 5000

looks like its trying to execute rails server command on a directory that is not a rails project. Set the correct app path in your configuration.

Related

Rails 6 image upload to digitalocean spaces

I have a blog that uploads banner and thumbnail images. I originally had it set to upload to the local directory using the carrierwave gem and I wanted to try to use digitalocean spaces since the app is deployed to the digitalocean app platform. I am able to get it working on localhost:3000 but when I deploy it to digitalocean it keeps reverting back to a previous deployment saying that a health check failed but not real errors.
I decided to deploy it to heroku since I am able to get actual errors. Here is the current error I get from heroku:
2021-03-09T22:41:10.466080+00:00 heroku[web.1]: Starting process with command `bin/rails server -p ${PORT:-5000} -e production`
2021-03-09T22:41:20.121636+00:00 app[web.1]: => Booting Puma
2021-03-09T22:41:20.121679+00:00 app[web.1]: => Rails 6.1.3 application starting in production
2021-03-09T22:41:20.121679+00:00 app[web.1]: => Run `bin/rails server --help` for more startup options
2021-03-09T22:41:31.105804+00:00 app[web.1]: [fog][WARNING] Unable to fetch credentials: Connection refused - connect(2) for 169.254.169.254:80 (Errno::ECONNREFUSED)
2021-03-09T22:41:31.108732+00:00 app[web.1]: Exiting
2021-03-09T22:41:31.110380+00:00 app[web.1]: /app/vendor/bundle/ruby/3.0.0/gems/fog-core-2.2.3/lib/fog/core/service.rb:244:in `validate_options': Missing required arguments: aws_access_key_id, aws_secret_access_key (ArgumentError)
2021-03-09T22:41:31.110386+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/fog-core-2.2.3/lib/fog/core/service.rb:268:in `handle_settings'
2021-03-09T22:41:31.110391+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/fog-core-2.2.3/lib/fog/core/service.rb:98:in `new'
2021-03-09T22:41:31.110426+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/fog-core-2.2.3/lib/fog/core/services_mixin.rb:30:in `new'
2021-03-09T22:41:31.110427+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/carrierwave-2.2.0/lib/carrierwave/storage/fog.rb:68:in `eager_load'
2021-03-09T22:41:31.110431+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/carrierwave-2.2.0/lib/carrierwave.rb:77:in `block in <class:Railtie>'
2021-03-09T22:41:31.110435+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3/lib/active_support/lazy_load_hooks.rb:68:in `block in execute_hook'
2021-03-09T22:41:31.110467+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
2021-03-09T22:41:31.110472+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
2021-03-09T22:41:31.110473+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
2021-03-09T22:41:31.110508+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3/lib/active_support/lazy_load_hooks.rb:51:in `each'
2021-03-09T22:41:31.111096+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
2021-03-09T22:41:31.111100+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3/lib/rails/application/finisher.rb:129:in `block in <module:Finisher>'
2021-03-09T22:41:31.111101+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3/lib/rails/initializable.rb:32:in `instance_exec'
2021-03-09T22:41:31.111127+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3/lib/rails/initializable.rb:32:in `run'
2021-03-09T22:41:31.111132+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3/lib/rails/initializable.rb:61:in `block in run_initializers'
2021-03-09T22:41:31.111132+00:00 app[web.1]: from /app/vendor/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:228:in `block in tsort_each'
2021-03-09T22:41:31.111164+00:00 app[web.1]: from /app/vendor/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
2021-03-09T22:41:31.111168+00:00 app[web.1]: from /app/vendor/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:431:in `each_strongly_connected_component_from'
2021-03-09T22:41:31.111169+00:00 app[web.1]: from /app/vendor/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:349:in `block in each_strongly_connected_component'
2021-03-09T22:41:31.111201+00:00 app[web.1]: from /app/vendor/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `each'
2021-03-09T22:41:31.111202+00:00 app[web.1]: from /app/vendor/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `call'
2021-03-09T22:41:31.111772+00:00 app[web.1]: from /app/vendor/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `each_strongly_connected_component'
2021-03-09T22:41:31.111777+00:00 app[web.1]: from /app/vendor/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:226:in `tsort_each'
2021-03-09T22:41:31.111777+00:00 app[web.1]: from /app/vendor/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:205:in `tsort_each'
2021-03-09T22:41:31.111781+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3/lib/rails/initializable.rb:60:in `run_initializers'
2021-03-09T22:41:31.111808+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3/lib/rails/application.rb:384:in `initialize!'
2021-03-09T22:41:31.111809+00:00 app[web.1]: from /app/config/environment.rb:5:in `<main>'
2021-03-09T22:41:31.111813+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
2021-03-09T22:41:31.111839+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
2021-03-09T22:41:31.111844+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
2021-03-09T22:41:31.111844+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
2021-03-09T22:41:31.111845+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
2021-03-09T22:41:31.111845+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
2021-03-09T22:41:31.111848+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:332:in `block in require'
2021-03-09T22:41:31.111851+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:299:in `load_dependency'
2021-03-09T22:41:31.111884+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:332:in `require'
2021-03-09T22:41:31.112296+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:53:in `require_relative'
2021-03-09T22:41:31.112301+00:00 app[web.1]: from config.ru:3:in `block in <main>'
2021-03-09T22:41:31.112302+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `eval'
2021-03-09T22:41:31.112334+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `new_from_string'
2021-03-09T22:41:31.112339+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/builder.rb:105:in `load_file'
2021-03-09T22:41:31.112340+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/builder.rb:66:in `parse_file'
2021-03-09T22:41:31.112367+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/server.rb:349:in `build_app_and_options_from_config'
2021-03-09T22:41:31.112368+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/server.rb:249:in `app'
2021-03-09T22:41:31.112372+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/server.rb:422:in `wrapped_app'
2021-03-09T22:41:31.112398+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/server.rb:312:in `block in start'
2021-03-09T22:41:31.112403+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/server.rb:379:in `handle_profiling'
2021-03-09T22:41:31.112809+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/server.rb:311:in `start'
2021-03-09T22:41:31.112813+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3/lib/rails/commands/server/server_command.rb:39:in `start'
2021-03-09T22:41:31.112841+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3/lib/rails/commands/server/server_command.rb:144:in `block in perform'
2021-03-09T22:41:31.112845+00:00 app[web.1]: from <internal:kernel>:90:in `tap'
2021-03-09T22:41:31.112846+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3/lib/rails/commands/server/server_command.rb:135:in `perform'
2021-03-09T22:41:31.112877+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
2021-03-09T22:41:31.112881+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
2021-03-09T22:41:31.112882+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
2021-03-09T22:41:31.112912+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3/lib/rails/command/base.rb:69:in `perform'
2021-03-09T22:41:31.114191+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3/lib/rails/command.rb:50:in `invoke'
2021-03-09T22:41:31.114195+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3/lib/rails/commands.rb:18:in `<main>'
2021-03-09T22:41:31.114196+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
2021-03-09T22:41:31.114229+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
2021-03-09T22:41:31.114234+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
2021-03-09T22:41:31.114234+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
2021-03-09T22:41:31.114261+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
2021-03-09T22:41:31.114262+00:00 app[web.1]: from bin/rails:5:in `<main>'
2021-03-09T22:41:31.238223+00:00 heroku[web.1]: Process exited with status 1
2021-03-09T22:41:31.311694+00:00 heroku[web.1]: State changed from starting to crashed
After the server starts it crashes saying fog cannot get the credentials.
Here is my initializer/carrierwave.rb file:
CarrierWave.configure do |config|
config.fog_credentials = {
provider: 'AWS', # required
aws_access_key_id: Rails.application.credentials.aws(:digitalocean_spaces_key), # required unless using use_iam_profile
aws_secret_access_key: Rails.application.credentials.aws(:digitalocean_spaces_secret), # required unless using use_iam_profile
use_iam_profile: true, # optional, defaults to false
region: 'nyc3', # optional, defaults to 'us-east-1'
host: 'nyc3.digitaloceanspaces.com', # optional, defaults to nil
endpoint: 'https://nyc3.digitaloceanspaces.com' # optional, defaults to nil
}
config.fog_directory = 'judo' # required
config.fog_public = true # optional, defaults to true
#config.fog_attributes = { cache_control: "public, max-age=#{365.days.to_i}" } # optional, defaults to {}
# For an application which utilizes multiple servers but does not need caches persisted across requests,
# uncomment the line :file instead of the default :storage. Otherwise, it will use AWS as the temp cache store.
# config.cache_storage = :file
end
Here is another attempt at the carrierwave.rb file:
CarrierWave.configure do |config|
config.fog_credentials = {
provider: 'AWS', # required
digitalocean_spaces_key_id: Rails.application.credentials.digitalocean_spaces_key, # required unless using use_iam_profile
digitalocean_spaces_secret: Rails.application.credentials.digitalocean_spaces_secret,
digitalocean_spaces_bucket: Rails.application.credentials.digitalocean_spaces_bucket,
use_iam_profile: true, # optional, defaults to false
region: 'nyc3', # optional, defaults to 'us-east-1'
host: 'nyc3.digitaloceanspaces.com', # optional, defaults to nil
endpoint: 'https://nyc3.digitaloceanspaces.com' # optional, defaults to nil
}
config.fog_directory = 'judo' # required
config.fog_public = true # optional, defaults to true
#config.fog_attributes = { cache_control: "public, max-age=#{365.days.to_i}" } # optional, defaults to {}
# For an application which utilizes multiple servers but does not need caches persisted across requests,
# uncomment the line :file instead of the default :storage. Otherwise, it will use AWS as the temp cache store.
# config.cache_storage = :file
end
Here is my credentials.yml file:
production:
digitalocean_spaces_key: <%= ENV["DIGITALOCEAN_SPACES_KEY"] %>
digitalocean_spaces_secret: <%= ENV["DIGITALOCEAN_SPACES_SECRET"] %>
digitalocean_spaces_bucket: <%= ENV["DIGITALOCEAN_SPACES_BUCKET"] %>
development:
digitalocean_spaces_key: my_key
digitalocean_spaces_secret: my_secret
digitalocean_spaces_bucket: judo
I entered the spaces key, secret, and bucket as app level variables in the app on digitalocean.
Here is my uploaders/banner_uploader.rb file:
class BannerUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
#include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
# storage :file
storage :fog
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}"
end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url(*args)
# # For Rails 3.1+ asset pipeline compatibility:
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
#
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process scale: [200, 300]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
# version :thumb do
# process resize_to_fit: [50, 50]
# end
# Add an allowlist of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_allowlist
%w(jpg jpeg gif png)
end
# Override the filename of the uploaded files:
# Avoid using model.id or version_name here, see uploader/store.rb for details.
# def filename
# "something.jpg" if original_filename
# end
end
Here is my post.rb:
class Post < ApplicationRecord
belongs_to :user
has_many :comments, as: :commentable, dependent: :destroy
# Active Storage from Rails 5
#has_one_attached :thumbnail
#has_one_attached :banner
# Action Text from Rails 6
has_rich_text :body
mount_uploader :banner, BannerUploader
validates :title, length: { minimum: 5 }
validates :body, length: { minimum: 25 }
self.per_page = 10
extend FriendlyId
friendly_id :title, use: :slugged
end
And here is my Gemfile:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '3.0.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem 'rails', '~> 6.1.3'
# Use Puma as the app server
gem 'puma', '~> 5.0'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 5.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Active Storage variant
gem 'image_processing', '~> 1.2'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.4', require: false
group :development, :test do
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4'
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 4.1.0'
# Display performance information such as SQL time and flame graphs for each request in your browser.
# Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
# gem 'rack-mini-profiler', '~> 2.0'
gem 'listen', '~> 3.3'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
group :production do
gem 'pg'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 3.26'
gem 'selenium-webdriver'
# Easy installation and use of web drivers to run system tests with browsers
gem 'webdrivers'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'devise'
gem 'simple_form'
gem 'faker'
gem 'will_paginate'
gem 'friendly_id'
gem "carrierwave"
gem "mime-types"
gem "fog-aws"
It seems like the server can't access to the content of the credentials.yml. This file is encrypted and Rails use the master key store in the master.key file to read it. So given that the master.key is not checked into version control, you need to provide it manually on the server. Please check this article https://medium.com/cedarcode/rails-5-2-credentials-9b3324851336
This section :
Deploying master key
When you move your code to a server, you need to make sure that your config/credentials.yml.enc file can be decrypted. That means that somehow you’ll need to provide Rails with your master key, given that it is not checked into version control.
There are two ways of doing that:
Option 1: Place the config/master.key file in the server. You’ll normally want to symlink this file to a shared folder in the server filesystem. Again, do not version your config/master.key file.
Option 2: create a RAILS_MASTER_KEY ENV variable. Rails will detect it and use it as your master key, e.g. in heroku: heroku config:set RAILS_MASTER_KEY=.
You should be able to use any of those indistinctly.
If you are using RBENV as you ruby manager, you can store your env var doing this :
You will create .rbenv-vars in your project folder, not your rails project folder but the folder in which is your project folder, the parent folder if you want.
After that you put your env var inside the file like this:
DATABASE_PWD=*****
no quotes, no space too before ou after the "="
For more check this link on goRails : https://gorails.com/deploy/ubuntu/18.04#capistrano
Hope this can help

Can't deploy a basic Rails app on Heroku

First of all I am a newbie with Ruby on Rails so sorry if the question seem stupid.
I am following a tutorial about Heroku for Rails app and when I run git push heroku master and go to check on the actual website, I get this message:
We're sorry, but something went wrong. If you are the application owner check the logs for more information.
When I run heroku logs in my console, I get the following:
2018-05-20T03:33:23.748800+00:00 app[api]: Enable Logplex by user xxx.romain#gmail.com
2018-05-20T03:33:23.554110+00:00 app[api]: Release v1 created by user xxx.romain#gmail.com
2018-05-20T03:33:23.748800+00:00 app[api]: Release v2 created by user xxx.romain#gmail.com
2018-05-20T03:33:23.554110+00:00 app[api]: Initial release by user xxx.romain#gmail.com
2018-05-20T03:33:46.000000+00:00 app[api]: Build started by user xxx.romain#gmail.com
2018-05-20T03:34:29.457658+00:00 app[api]: Set LANG, RACK_ENV, RAILS_ENV, RAILS_LOG_TO_STDOUT, RAILS_SERVE_STATIC_FILES, SECRET_KEY_BASE config vars by user xxx.romain#gmail.com
2018-05-20T03:34:29.457658+00:00 app[api]: Release v3 created by user xxx.romain#gmail.com
2018-05-20T03:34:30.828730+00:00 app[api]: Release v4 created by user xxx.romain#gmail.com
2018-05-20T03:34:30.828730+00:00 app[api]: Attach DATABASE (#ref:postgresql-tapered-27211) by user xxx.romain#gmail.com
2018-05-20T03:34:31.131189+00:00 app[api]: Scaled to console#0:Free rake#0:Free web#1:Free worker#0:Free by user xxx.romain#gmail.com
2018-05-20T03:34:31.115804+00:00 app[api]: Release v5 created by user xxx.romain#gmail.com
2018-05-20T03:34:31.115804+00:00 app[api]: Deploy 0248e11a by user xxx.romain#gmail.com
2018-05-20T03:34:31.000000+00:00 app[api]: Build succeeded
2018-05-20T03:34:36.168184+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 57618 -e production`
2018-05-20T03:34:41.855283+00:00 app[web.1]: => Booting Puma
2018-05-20T03:34:41.855302+00:00 app[web.1]: => Rails 5.1.6 application starting in production
2018-05-20T03:34:41.855303+00:00 app[web.1]: => Run `rails server -h` for more startup options
2018-05-20T03:34:41.855305+00:00 app[web.1]: Puma starting in single mode...
2018-05-20T03:34:41.855313+00:00 app[web.1]: * Version 3.11.4 (ruby 2.3.4-p301), codename: Love Song
2018-05-20T03:34:41.855315+00:00 app[web.1]: * Min threads: 5, max threads: 5
2018-05-20T03:34:41.855316+00:00 app[web.1]: * Environment: production
2018-05-20T03:34:41.855503+00:00 app[web.1]: * Listening on tcp://0.0.0.0:57618
2018-05-20T03:34:41.855969+00:00 app[web.1]: Use Ctrl-C to stop
2018-05-20T03:34:42.411033+00:00 heroku[web.1]: State changed from starting to up
2018-05-20T03:34:43.450895+00:00 app[web.1]: [5a2cc1ab-9701-42e6-accc-2f372ff837f1] Started GET "/" for 27.32.8.50 at 2018-05-20 03:34:43 +0000
2018-05-20T03:34:43.487004+00:00 app[web.1]: [5a2cc1ab-9701-42e6-accc-2f372ff837f1] Rendering keywords/index.html.erb within layouts/application
2018-05-20T03:34:43.463124+00:00 app[web.1]: [5a2cc1ab-9701-42e6-accc-2f372ff837f1] Processing by KeywordsController#index as HTML
2018-05-20T03:34:44.722888+00:00 heroku[router]: at=info method=GET path="/" host=tweetscoperm.herokuapp.com request_id=5a2cc1ab-9701-42e6-accc-2f372ff837f1 fwd="27.32.8.50" dyno=web.1 connect=1ms service=1278ms status=500 bytes=1827 protocol=https
2018-05-20T03:34:44.715829+00:00 app[web.1]: [5a2cc1ab-9701-42e6-accc-2f372ff837f1] Keyword Load (2.3ms) SELECT "keywords".* FROM "keywords"
2018-05-20T03:34:44.717471+00:00 app[web.1]: [5a2cc1ab-9701-42e6-accc-2f372ff837f1] Rendered keywords/index.html.erb within layouts/application (1230.3ms)
2018-05-20T03:34:44.717773+00:00 app[web.1]: [5a2cc1ab-9701-42e6-accc-2f372ff837f1] Completed 500 Internal Server Error in 1254ms (ActiveRecord: 33.5ms)
2018-05-20T03:34:44.719239+00:00 app[web.1]: [5a2cc1ab-9701-42e6-accc-2f372ff837f1]
2018-05-20T03:34:44.720128+00:00 app[web.1]: [5a2cc1ab-9701-42e6-accc-2f372ff837f1] ActionView::Template::Error (PG::UndefinedTable: ERROR: relation "keywords" does not exist
2018-05-20T03:34:44.720132+00:00 app[web.1]: ^
2018-05-20T03:34:44.720130+00:00 app[web.1]: LINE 1: SELECT "keywords".* FROM "keywords"
2018-05-20T03:34:44.720134+00:00 app[web.1]: : SELECT "keywords".* FROM "keywords"):
2018-05-20T03:34:44.720461+00:00 app[web.1]: [5a2cc1ab-9701-42e6-accc-2f372ff837f1] 11: </thead>
2018-05-20T03:34:44.720464+00:00 app[web.1]: [5a2cc1ab-9701-42e6-accc-2f372ff837f1] 12:
2018-05-20T03:34:44.720466+00:00 app[web.1]: [5a2cc1ab-9701-42e6-accc-2f372ff837f1] 13: <tbody>
2018-05-20T03:34:44.720468+00:00 app[web.1]: [5a2cc1ab-9701-42e6-accc-2f372ff837f1] 14: <% #keywords.each do |keyword| %>
2018-05-20T03:34:44.720469+00:00 app[web.1]: [5a2cc1ab-9701-42e6-accc-2f372ff837f1] 15: <tr>
2018-05-20T03:34:44.720471+00:00 app[web.1]: [5a2cc1ab-9701-42e6-accc-2f372ff837f1] 16: <td><%= keyword.word %></td>
2018-05-20T03:34:44.720473+00:00 app[web.1]: [5a2cc1ab-9701-42e6-accc-2f372ff837f1] 17: <td><%= link_to 'Show', keyword %></td>
2018-05-20T03:34:44.720531+00:00 app[web.1]: [5a2cc1ab-9701-42e6-accc-2f372ff837f1]
2018-05-20T03:34:44.720593+00:00 app[web.1]: [5a2cc1ab-9701-42e6-accc-2f372ff837f1] app/views/keywords/index.html.erb:14:in `_app_views_keywords_index_html_erb___2939922413078681924_23601960'
2018-05-20T03:34:45.523130+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=tweetscoperm.herokuapp.com request_id=ec46bf49-b91c-4bf2-b017-a15b4cef63a8 fwd="27.32.8.50" dyno=web.1 connect=1ms service=2ms status=200 bytes=143 protocol=https
Looking at that, I couldn't find any reason that would cause a problem.
So far, here is how my database.yml file looks like:
development:
adapter: postgresql
database: tscope_dev
pool: 5
timeout: 5000
test:
adapter: postgresql
database: tscope_test
pool: 5
timeout: 5000
production:
adapter: postgresql
database: tscope_production
pool: 5
timeout: 5000
And my gemfile:
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.6'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3'
# Using PostgreSQL as DB
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'rails_12factor', group: :production
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
ruby '2.3.4'
I created the databse and did the migrations and also ran bundle install as well. It is the most basic application with just one controller generated with a scaffold.
Does anybody has any idea of what could be the problem? Even the smallest tip would help me since I really don't know what to look at right now.
If you need any futher information about my code, feel free to ask.
Thanks in advance :)
EDIT
Solved this issue by running heroku run rake db:migratein the console.
Turned out I haven't ran the migration on Heroku.
This line:
ActionView::Template::Error (PG::UndefinedTable: ERROR: relation "keywords" does not exist
suggests you haven't run your migrations on heroku.
To do that, in your console do:
heroku run rake db:migrate

Heroku/Rails error, logs not very helpful

I have recently developed my first Ruby on Rails app and have tried to deploy it to Heroku, however when I try to load the app URL, it just returns with this page:
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
Here are my logs:
2015-01-27T14:11:44.782093+00:00 heroku[api]: Release v12 created by tom#tomoakley.me
2015-01-27T14:11:45.419564+00:00 heroku[web.1]: State changed from up to starting
2015-01-27T14:11:48.394740+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 21006 -e production`
2015-01-27T14:11:49.304740+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2015-01-27T14:11:50.179113+00:00 app[web.1]: [2015-01-27 14:11:50] FATAL SignalException: SIGTERM
2015-01-27T14:11:50.179123+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:32:in `start'
2015-01-27T14:11:50.179120+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in `select'
2015-01-27T14:11:50.179121+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in `block in start'
2015-01-27T14:11:50.179126+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/handler/webrick.rb:35:in `run'
2015-01-27T14:11:50.179124+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:160:in `start'
2015-01-27T14:11:50.179133+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `server'
2015-01-27T14:11:50.179152+00:00 app[web.1]: bin/rails:8:in `require'
2015-01-27T14:11:50.179150+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
2015-01-27T14:11:50.179130+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:80:in `block in server'
2015-01-27T14:11:50.179128+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/server.rb:80:in `start'
2015-01-27T14:11:50.179161+00:00 app[web.1]: [2015-01-27 14:11:50] INFO WEBrick::HTTPServer#start done.
2015-01-27T14:11:50.179127+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/server.rb:286:in `start'
2015-01-27T14:11:50.179160+00:00 app[web.1]: [2015-01-27 14:11:50] INFO going to shutdown ...
2015-01-27T14:11:50.179131+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `tap'
2015-01-27T14:11:50.179151+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
2015-01-27T14:11:50.179153+00:00 app[web.1]: bin/rails:8:in `<main>'
2015-01-27T14:11:50.265926+00:00 app[web.1]: => Booting WEBrick
2015-01-27T14:11:50.265932+00:00 app[web.1]: => Rails 4.2.0 application starting in production on http://0.0.0.0:39482
2015-01-27T14:11:50.265936+00:00 app[web.1]: => Ctrl-C to shutdown server
2015-01-27T14:11:50.265934+00:00 app[web.1]: => Run `rails server -h` for more startup options
2015-01-27T14:11:50.265937+00:00 app[web.1]: Exiting
2015-01-27T14:11:51.162075+00:00 heroku[web.1]: Process exited with status 143
2015-01-27T14:11:52.030623+00:00 app[web.1]: [2015-01-27 14:11:52] INFO ruby 2.0.0 (2014-11-13) [x86_64-linux]
2015-01-27T14:11:52.030600+00:00 app[web.1]: [2015-01-27 14:11:52] INFO WEBrick 1.3.1
2015-01-27T14:11:52.030938+00:00 app[web.1]: [2015-01-27 14:11:52] INFO WEBrick::HTTPServer#start: pid=3 port=21006
2015-01-27T14:11:52.681188+00:00 heroku[web.1]: State changed from starting to up
2015-01-27T14:12:57.646409+00:00 heroku[router]: at=info method=GET path="/" host=www.biblequot.es request_id=8125c7b1-2590-4162-b98f-0b849febe74e fwd="94.175.136.230" dyno=web.1 connect=3ms service=1175ms status=500 bytes=1754
I was previously trying to work out how to keep the Secret Keys in config/secrets.yml from being on Github (the repo will be public) and tried to install GPG and use dotgpg (using the guide here) but I couldn't get it to work properly so took it out of my Gemfile, which I've copied in below:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use font-awesome!
gem 'font-awesome-sass'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
And also for good measure, here is my config/enviroment/production.rb file:
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = true
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end
Sorry for putting so much stuff here, I just hope someone can resolve my problem quickly :) Also as a bonus, what's the best way to hide the secret keys in secrets.yml? Does it matter if the development and test keys are there? (the production key is hidden in an environment variable). Thanks!
In your logs, it looks like your application received a Sigterm, but when you see the rails error message
"We're sorry, but something went wrong." It mean the server started, and the error is inside your rails application.
So we need to see more of your logs to help you.
The easiest way for environement variable is to create a .env.sample with examples of environement variable and every developer creates it's own .env file and use dotenv-rails with gem 'dotenv-rails', groups: [:development, :test] inside your Gemfile
You can even replace your database.yml with :
DATABASE_URL=postgres://username:password#localhost:5432/database_name
But dotgpg looks great, I will try to use it.
in your project directory, run
heroku run console
it should give you more info

Can't activate rails (= 2.3.15), already activated rails-3.2.17

I'm trying to upgrade from Rails 2.3.15 to 3.2.17
I did bundle update, and changed controller syntax as needed.
Trying to start the server and I'm getting the following error, is anyone familiar with this?
>> bundle exec script/server
/opt/boxen/rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/bundler-1.7.0/lib/bundler/rubygems_integration.rb:266:in `block in replace_gem': can't activate rails (= 2.3.15), already activated rails-3.2.17. Make sure all dependencies are added to Gemfile. (Gem::LoadError)
from /Users/neo/src/myapp/config/boot.rb:60:in `load_rails_gem'
from /Users/neo/src/myapp/config/boot.rb:54:in `load_initializer'
from /Users/neo/src/myapp/config/boot.rb:38:in `run'
from /Users/neo/src/myapp/boot.rb:11:in `boot!'
from /Users/neo/src/myapp/config/boot.rb:114:in `<top (required)>'
from script/server:2:in `require'
from script/server:2:in `<main>'
My Gemfile:
source "https://rubygems.org"
#ruby "1.8.7", :group => :staging
gem 'rails', '3.2.17'
gem 'rake', '0.9.2'
gem "aws-s3", :require => "aws/s3"
gem 'authlogic', '~> 2.1.1'
gem 'RedCloth', :require => "redcloth"
gem 'logging'
gem 'panda'
gem 'hoptoad_notifier'
gem 'fastercsv'
gem "comma", "~> 2.0" # specifying -v to add support to rails 2
gem 'pg'
gem 'cloudfront-signer'
gem 'newrelic_rpm'
gem 'thin'
group :development do
gem 'heroku'
gem 'taps'
gem 'sqlite3'
gem 'pry'
gem 'rdoc'
end
gem 'heroku_san'
group :test do
gem 'pg'
end
Any help would be greatly appreciated! thank you
EDIT:
With rails s or bundle exec rails s / server, I just get the about rails message, like below:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /opt/boxen/rbenv/versions/1.9.3-p545/bin/ruby
-b, [--builder=BUILDER] # Path to a application builder (can be a filesystem path or URL)
-m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL)
[--skip-gemfile], [--no-skip-gemfile] # Don't create a Gemfile
[--skip-bundle], [--no-skip-bundle] # Don't run bundle install
-G, [--skip-git], [--no-skip-git] # Skip Git ignores and keeps
-O, [--skip-active-record], [--no-skip-active-record] # Skip Active Record files
-S, [--skip-sprockets], [--no-skip-sprockets] # Skip Sprockets files
-d, [--database=DATABASE] # Preconfigure for selected database .
.
.
You should be using
bundle exec rails server
EDIT: Everything that used to be in the script directory is now managed by the rails command. When upgrading, I found it much easier to use a gemset to isolate the new gems from the old as it was often necessary to switch back and forth, and the new rails command will not play nicely with the old.
Rails 3 using new command syntax for start server, console, scaffold etc.
In rails 3 script/* got replaced by script/rails
So, you need to start your server like:
rails s
OR
rails server

Heroku:The page you were looking for doesn't exist No route matches [GET] "/"

I'm new to Rails. This question has been asked a lot but unfortunately none of the solutions provided have worked for me.
On Heroku, visiting the app URL after pushing my files with git push heroku master gives me the error:
The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved.
Here's my log:
2014-05-17T12:31:00.796904+00:00 app[web.1]: [2014-05-17 12:31:00] INFO WEBrick::HTTPServer#start done.
2014-05-17T12:31:00.796853+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:160:in `start'
2014-05-17T12:31:00.796864+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/commands/com
mands_tasks.rb:40:in `run_command!'
2014-05-17T12:31:00.796850+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in `block in
start'
2014-05-17T12:31:00.796866+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/commands.rb:
17:in `<top (required)>'
2014-05-17T12:31:00.796840+00:00 app[web.1]: [2014-05-17 12:31:00] FATAL SignalException: SIGTERM
2014-05-17T12:31:00.796868+00:00 app[web.1]: bin/rails:4:in `require'
2014-05-17T12:31:00.796855+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.r
b:14:in `run'
2014-05-17T12:31:00.796869+00:00 app[web.1]: bin/rails:4:in `<main>'
2014-05-17T12:31:00.796856+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:264:in
`start'
2014-05-17T12:31:00.796876+00:00 app[web.1]: [2014-05-17 12:31:00] INFO going to shutdown ...
2014-05-17T12:31:00.796858+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/commands/ser
ver.rb:69:in `start'
2014-05-17T12:31:00.796944+00:00 app[web.1]: Exiting
2014-05-17T12:31:00.796860+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/commands/com
mands_tasks.rb:81:in `block in server'
2014-05-17T12:31:00.138102+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2014-05-17T12:31:02.926026+00:00 heroku[web.1]: Process exited with status 143
Here's my Gemfile:
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.1'
# Use sqlite3 as the database for Active Record
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
gem 'rails_log_stdout', github: 'heroku/rails_log_stdout'
gem 'rails3_serve_static_assets', github: 'heroku/rails3_serve_static_assets'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]
I've also modified my production.rb by addding:
#config/environments/production.rb
config.assets.compile = true
# Heroku also requires this to be false
config.assets.initialize_on_precompile=false
and here's my routes.rb:
Rails.application.routes.draw do
exit
most of the code in this file is commented.
Please help?
Edit
O.k. so after looking at the files you have, I do not see any pages to view which means heroku has nothing to display. First off I want to recommend the ruby on rails tutorial by Micheal Hartl. You can find it free by googling "ruby on rails tutorial hartl", this will explain Ruby on rails better than I ever could, if you work through it and feel like it helped I believe you can donate some money for using it and I would recommend that because it is an amazing resource that I, and probably many others, have used to learn ruby on rails.
O.k. first why your code is not working. You have root 'welcome#index' in routes.rb. But there is no welcome_controller.rb with an 'index' action. To create that from command line type (capitaliazation is important here)
rails generate controller Welcome index
This will create an index page (the one you have in your routes file), it creates the view and the 'welcome' controller for it automatically. You can call the page anything you want but this will work for the code you already have in routes.rb. You will understand this more when you work through the tutorial. This will also create a lot of files, again the tutorial will help you understand what all that is. I am only trying to solve the issue you posted about right here and stay on topic as best I can while getting you going in the right direction.
After that you will have to push to git again and then push to heroku. When you open heroku again it should land on that page, there will not be anything on the page other than a generic message, I think you should see something along the lines of "find me in app/views/welcome/index.rb" If you see that your routing is working.

Resources