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
Related
So I've been having this problem for sometime since I started working with the websocket-rails gem. Apparently it can't autoload my 'broadcast controller' and is preventing me from running rails commands on the command line.
I used to get around this be commenting out the events file and getting things to load. Its honestly a crapshoot, sometimes it works sometimes it doesn't but lately I havn't been getting it to work, I've been trying to debugg this for a while but honestly I'm stuck.
This only happens in development.
Anyone have any ideas?
Here is the error stack:
/Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:513:in `load_missing_constant': Unable to autoload constant BroadcastsController, expected /Users/matt/Documents/sdcc_grp_buy/app/controllers/broadcasts_controller.rb to define it (LoadError)
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:203:in `const_missing'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/inflector/methods.rb:268:in `const_get'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/inflector/methods.rb:268:in `block in constantize'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/inflector/methods.rb:266:in `each'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/inflector/methods.rb:266:in `inject'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/inflector/methods.rb:266:in `constantize'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/core_ext/string/inflections.rb:66:in `constantize'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/bundler/gems/websocket-rails-3d4bc7cb73e2/lib/websocket_rails/event_map.rb:179:in `constantize_controller'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/bundler/gems/websocket-rails-3d4bc7cb73e2/lib/websocket_rails/event_map.rb:172:in `validate_string_target'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/bundler/gems/websocket-rails-3d4bc7cb73e2/lib/websocket_rails/event_map.rb:153:in `validate_target'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/bundler/gems/websocket-rails-3d4bc7cb73e2/lib/websocket_rails/event_map.rb:102:in `store'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/bundler/gems/websocket-rails-3d4bc7cb73e2/lib/websocket_rails/event_map.rb:60:in `subscribe'
from /Users/matt/Documents/sdcc_grp_buy/config/events.rb:20:in `block in <top (required)>'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/bundler/gems/websocket-rails-3d4bc7cb73e2/lib/websocket_rails/event_map.rb:55:in `instance_eval'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/bundler/gems/websocket-rails-3d4bc7cb73e2/lib/websocket_rails/event_map.rb:55:in `evaluate'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/bundler/gems/websocket-rails-3d4bc7cb73e2/lib/websocket_rails/event_map.rb:30:in `initialize'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/bundler/gems/websocket-rails-3d4bc7cb73e2/lib/websocket_rails/dispatcher.rb:13:in `new'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/bundler/gems/websocket-rails-3d4bc7cb73e2/lib/websocket_rails/dispatcher.rb:13:in `initialize'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/bundler/gems/websocket-rails-3d4bc7cb73e2/lib/websocket_rails/connection_manager.rb:32:in `new'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/bundler/gems/websocket-rails-3d4bc7cb73e2/lib/websocket_rails/connection_manager.rb:32:in `initialize'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/bundler/gems/websocket-rails-3d4bc7cb73e2/lib/rails/config/routes.rb:3:in `new'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/bundler/gems/websocket-rails-3d4bc7cb73e2/lib/rails/config/routes.rb:3:in `block in <top (required)>'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.7/lib/action_dispatch/routing/route_set.rb:391:in `instance_exec'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.7/lib/action_dispatch/routing/route_set.rb:391:in `eval_block'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.7/lib/action_dispatch/routing/route_set.rb:373:in `draw'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/bundler/gems/websocket-rails-3d4bc7cb73e2/lib/rails/config/routes.rb:1:in `<top (required)>'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:287:in `load'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:287:in `block in load'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:259:in `load_dependency'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:287:in `load'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/railties-5.0.7/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/railties-5.0.7/lib/rails/application/routes_reloader.rb:40:in `each'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/railties-5.0.7/lib/rails/application/routes_reloader.rb:40:in `load_paths'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/railties-5.0.7/lib/rails/application/routes_reloader.rb:16:in `reload!'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/railties-5.0.7/lib/rails/application/routes_reloader.rb:26:in `block in updater'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/file_update_checker.rb:77:in `execute'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/railties-5.0.7/lib/rails/application/routes_reloader.rb:7:in `execute'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/railties-5.0.7/lib/rails/application/finisher.rb:132:in `block (2 levels) in <module:Finisher>'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/callbacks.rb:396:in `instance_exec'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/callbacks.rb:396:in `block in make_lambda'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/callbacks.rb:169:in `block (2 levels) in halting'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/callbacks.rb:547:in `block (2 levels) in default_terminator'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/callbacks.rb:546:in `catch'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/callbacks.rb:546:in `block in default_terminator'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/callbacks.rb:170:in `block in halting'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/callbacks.rb:454:in `block in call'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/callbacks.rb:454:in `each'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/callbacks.rb:454:in `call'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/callbacks.rb:101:in `__run_callbacks__'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/callbacks.rb:750:in `_run_run_callbacks'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/callbacks.rb:90:in `run_callbacks'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/execution_wrapper.rb:108:in `run!'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/reloader.rb:113:in `run!'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/reloader.rb:48:in `block (2 levels) in reload!'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/reloader.rb:46:in `tap'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/reloader.rb:46:in `block in reload!'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/execution_wrapper.rb:85:in `wrap'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.7/lib/active_support/reloader.rb:45:in `reload!'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:164:in `serve'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:141:in `block in run'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `loop'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `run'
from /Users/matt/Documents/sdcc_grp_buy/vendor/bundle/ruby/2.4.0/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in `<top (required)>'
from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'`
this is what /Users/matt/Documents/sdcc_grp_buy/app/controllers/broadcasts_controller.rb looks like:
class BroadcastsController < WebsocketRails::BaseController
def register_member_to_group
room = message[:room]
member_group_id = message[:member_group_id]
connection = message[:connection]
member_id = message[:member_id]
grp = Group.find(room)
number = grp.member_groups.count
WebsocketRails["group_#{room}"].trigger('member_registered', {room: room, member_group_id: member_group_id, member_id: member_id, connection_id: connection, :num_of_ppl => number})
end
def check_in_member
room = message[:room]
member_id = message[:member_id]
connection = message[:connection]
member = Member.find(member_id)
member.checked_in_date = Date.today
if member.save
WebsocketRails["global"].trigger('check_in_member', {room: room, member_id: member_id, connection_id: connection })
end
end
def check_out_member
room = message[:room]
member_id = message[:member_id]
connection = message[:connection]
member = Member.find(member_id)
member.checked_in_date = Date.today - 25.hours
if member.save
WebsocketRails["global"].trigger('check_out_member', {room: room, member_id: member_id, connection_id: connection })
end
end
def delete_member_from_group
room = message[:room]
member_group_id = message[:member_group_id]
connection = message[:connection]
grp = Group.find(room)
number = grp.member_groups.count
WebsocketRails["group_#{room}"].trigger('unregister_member', {room: room, member_group_id: member_group_id, connection_id: connection, :num_of_ppl => number })
end
def mark_member_as_covered_for_all_groups
member_id = message[:member_id]
end
def group_updated
group_id = message[:room]
count = message[:count]
total = count.split('/')[1]
covered = count.split('/')[0]
if covered == total
complete = true
else
complete = false
end
obj = {
group_id: group_id,
count: count,
complete: complete
}
WebsocketRails["global"].trigger('group_updated', obj)
end
def cover_member_for_group
room = message[:group_id]
member_group_id = message[:member_group_id]
member_id = MemberGroup.find(message[:member_group_id]).member.id
connection = message[:connection]
WebsocketRails["global"].trigger('member_covered', {member_id: member_id, member_group_id: member_group_id, group_id: room, connection_id: connection})
end
def someone_typing
room = message[:room]
connection = message[:connection]
WebsocketRails["group_#{room}"].trigger('someone_typing', {room: room, connection_id: connection})
end
def deactivate_member
member = Member.find(message[:member_id])
member.active = false
member.sponsor_id = nil
connection = message[:connection]
# maybe i need to loop in the JS and not in the controller
if member.save
WebsocketRails["global"].trigger('deactivate_member', { :member_id => member.id,connection_id: connection })
else
puts 'ERROR'
end
end
def activate_member
member = Member.find(message[:member_id])
member.active = true
member.sponsor_id = current_user.id
connection = message[:connection]
# maybe i need to loop in the JS and not in the controller
if member.save
WebsocketRails["global"].trigger('activate_member', { :member_id => member.id,connection_id: connection })
else
puts 'error'
puts member.errors.full_messages.join(',')
end
end
def send_chat_message
type = message[:type]
room = message[:room]
message_id = message[:message]
user_id = current_user.id
connection = message[:connection]
if type == 'group'
WebsocketRails["group_#{room}"].trigger('add_room_message', {room: room, message_id: message_id, user_id: message[:user_id], connection_id: connection})
else
WebsocketRails["global"].trigger('add_global_message', {message_id: message_id, user_id: message[:user_id], connection_id: connection})
end
end
end
and this is what my events.rb file looks like:
WebsocketRails::EventMap.describe do
# You can use this file to map incoming events to controller actions.
# One event can be mapped to any number of controller actions. The
# actions will be executed in the order they were subscribed.
# subscribe :client_connected, 'groups#new_user'
#
# Uncomment and edit the next line to handle the client connected event:
# subscribe :client_connected, :to => Controller, :with_method => :method_name
#
# Here is an example of mapping namespaced events:
# namespace :product do
# subscribe :new, :to => ProductController, :with_method => :new_product
# end
# namespace :chatroom do
# subscribe :create_room, "groups#create_room"
# subscribe :update_members, 'groups#update'
# end
# namespace :members do
subscribe :register_member, "broadcasts#register_member_to_group"
subscribe :unregister, "broadcasts#delete_member_from_group"
subscribe :cover_member, "broadcasts#cover_member_for_group"
subscribe :activate_member, "broadcasts#activate_member"
subscribe :deactivate_member, "broadcasts#deactivate_member"
subscribe :send_chat_message, "broadcasts#send_chat_message"
subscribe :someone_typing, "broadcasts#someone_typing"
subscribe :group_updated, "broadcasts#group_updated"
subscribe :check_in_member, "broadcasts#check_in_member"
subscribe :check_out_member, "broadcasts#check_out_member"
# end
# The above will handle an event triggered on the client like `product.new`.
end
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.0.4'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# 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.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'jquery-ui-rails'
# 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', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'devise'
gem 'faker'
gem 'omniauth'
gem 'activerecord-session_store'
# rails generate active_record:session_migration
# gem 'omniauth-facebook', '1.4.0'
gem 'omniauth-facebook'
gem 'bootstrap-sass', '~> 3.2.0'
gem 'autoprefixer-rails'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'``
gem 'dotenv-rails'
gem 'will_paginate', '~> 3.0.6'
gem 'redis', '~> 3.0'
# gem 'redis-namespace'
# Use Unicorn as the app server
# gem 'unicorn'
# gem 'websocket-rails'
gem 'react-rails'
gem 'twilio-ruby', '~> 5.10.5'
# gem 'webpacker'
gem 'webpacker', '~> 3.5'
gem 'websocket-rails', github: 'recurser/websocket-rails', branch: 'bugfix/388-latest-faye-websocket'
# gem 'websocket-rails'
# gem 'websocket-rails', github: 'moaa/websocket-rails', branch: 'threadsocket-rails'
# gem 'aws-sdk', '~> 2'
# gem 'aws-sdk-rails'
# gem 'csv'
group :development, :test do
gem 'sqlite3'
gem 'byebug'
gem 'listen'
# 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
group :production do
# gem 'websocket-rails' #, github: 'recurser/websocket-rails', branch: 'bugfix/388-latest-faye-websocket'
gem 'pg'
# gem 'mysql2'
gem 'rails_12factor', '0.0.2'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
# gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
development.rb:
Rails.application.configure do
# Verifies that versions and hashed value of the package contents in the project's package.json
config.webpacker.check_yarn_integrity = true
# Verifies that versions and hashed value of the package contents in the project's package.json
config.webpacker.check_yarn_integrity = true
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports.
config.consider_all_requests_local = true
config.action_mailer.perform_deliveries = true
# Enable/disable caching. By default caching is disabled.
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=172800'
}
else
config.action_controller.perform_caching = false
config.cache_store = :null_store
end
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = false
# Suppress logger output for asset requests.
config.assets.quiet = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
config.action_mailer.smtp_settings = {
:address => "email-smtp.us-west-2.amazonaws.com",
:port => 587,
:user_name => ENV["SES_SMTP_USERNAME"], #Your SMTP user
:password => ENV["SES_SMTP_PASSWORD"], #Your SMTP password
:authentication => :login,
:enable_starttls_auto => true
}
end
Figured it out, the spring servers was hanging, solved by doing this:
spring stop
ref: "rails generate" not working
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
I had a running app with no problem and just did bundle update and bundle install and now.
I had not bundle updated for the past 4 months I think.
Now when I run $ rails s, I have this error:
".../gems/sprockets-2.12.3/lib/sprockets/manifest.rb:65:in `read': Is a directory - .../public/assets (Errno::EISDIR)"!
mathieu-To-be-filled-by-O-E-M:~/rails_projects/mathieu_app$ rails s
DEPRECATION WARNING: Support for Rails < 4.1.0 will be dropped. (called from require at /home/mathieu/.rvm/gems/ruby-2.0.0-p451#global/gems/bundler-1.5.3/lib/bundler/runtime.rb:76)
=> Booting WEBrick
=> Rails 4.0.12 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
DEPRECATION WARNING: Model based mass assignment security has been extracted
out of Rails into a gem. Please use the new recommended protection model for
params or add `protected_attributes` to your Gemfile to use the old one.
To disable this message remove the `whitelist_attributes` option from your
`config/application.rb` file and any `mass_assignment_sanitizer` options
from your `config/environments/*.rb` files.
See http://guides.rubyonrails.org/security.html#mass-assignment for more information.
Exiting
/home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:65:in `read': Is a directory - /home/mathieu/rails_projects/mathieu_app/public/assets (Errno::EISDIR)
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:65:in `initialize'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/sprockets-rails-2.2.2/lib/sprockets/railtie.rb:105:in `new'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/sprockets-rails-2.2.2/lib/sprockets/railtie.rb:105:in `block in <class:Railtie>'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/activesupport-4.0.12/lib/active_support/lazy_load_hooks.rb:36:in `call'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/activesupport-4.0.12/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/activesupport-4.0.12/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/activesupport-4.0.12/lib/active_support/lazy_load_hooks.rb:44:in `each'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/activesupport-4.0.12/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/application/finisher.rb:62:in `block in <module:Finisher>'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/initializable.rb:30:in `instance_exec'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/initializable.rb:30:in `run'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/mathieu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
from /home/mathieu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
from /home/mathieu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
from /home/mathieu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
from /home/mathieu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:180:in `each'
from /home/mathieu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
from /home/mathieu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/initializable.rb:54:in `run_initializers'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/application.rb:215:in `initialize!'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/mathieu/rails_projects/mathieu_app/config/environment.rb:5:in `<top (required)>'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/activesupport-4.0.12/lib/active_support/dependencies.rb:229:in `require'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/activesupport-4.0.12/lib/active_support/dependencies.rb:229:in `block in require'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/activesupport-4.0.12/lib/active_support/dependencies.rb:214:in `load_dependency'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/activesupport-4.0.12/lib/active_support/dependencies.rb:229:in `require'
from /home/mathieu/rails_projects/mathieu_app/config.ru:3:in `block in <main>'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#global/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#global/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
from /home/mathieu/rails_projects/mathieu_app/config.ru:in `new'
from /home/mathieu/rails_projects/mathieu_app/config.ru:in `<main>'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#global/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#global/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#global/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#global/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#global/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/commands/server.rb:48:in `app'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#global/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/commands/server.rb:75:in `start'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/commands.rb:76:in `block in <top (required)>'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/commands.rb:71:in `tap'
from /home/mathieu/.rvm/gems/ruby-2.0.0-p451#rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/commands.rb:71:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
My gem list:
source 'https://rubygems.org'
ruby "2.0.0" # source: https://devcenter.heroku.com/articles/ruby-versions
# Rails 4
gem 'rails', "~> 4.0.3"
# Gems supporting Rails 4 core architecture
gem 'actionpack-action_caching'
gem 'actionpack-page_caching'
gem 'activerecord-session_store'
gem 'activeresource'
gem 'rails-observers'
gem 'turbolinks'
gem 'pg'
gem 'anjlab-bootstrap-rails', :require => 'bootstrap-rails',
:github => 'anjlab/bootstrap-rails',
:branch => '3.0.0'
gem 'devise' # authentification
gem 'cancan' # authorization
gem 'rolify', :git => 'git://github.com/EppO/rolify.git' # role management library with resource scoping, added fork due to bug source - stackoverflow.com/questions/13712012/error-pushing-to-heroku-aborting-my-rake-assetsprecompile?rq=1
gem 'figaro' # rails app configuration and keep private stuff...private
gem 'sendgrid' # sendgrid gem
gem 'faker' # to create fake user accounts
gem 'will_paginate' # pagination method
gem 'bootstrap-will_paginate' # configure will_paginate gem to bootstrap pagination style
gem 'font-awesome-rails' # pure css icons
gem 'validates_timeliness' # methods and validations for dates formats
gem 'validate_url' # for URL validations in forms
gem 'dotiw' # overrides the default distance_of_time_in_words and provides a more accurate output
gem 'friendly_id'
# Forms with formtastic
gem 'formtastic'
gem 'formtastic-bootstrap'
# Active admin stuff
gem 'activeadmin', github: 'gregbell/active_admin' # added github because of deployment issue wiht jquery ui http://stackoverflow.com/questions/16844411/rails-active-admin-deployment-couldnt-find-file-jquery-ui
gem 'sass-rails', '~> 4.0.1' # Master branch not OK with Rails 4, hence we point to branch that comply with Rails 4
gem 'kaminari' #'0.14.1' active admin needs kaminari for pagination; blocked on 0.14.1 because if not get nomethod error per_page kaminari https://github.com/sferik/rails_admin/issues/1868 and https://github.com/amatsuda/kaminari/issues/481
gem 'postgres_ext' # gives a nice set of query methods & Adds missing native PostgreSQL data types to ActiveRecord and convenient querying extensions for ActiveRecord and Arel for Rails 4.x
gem 'jquery-rails'
gem 'chosen-rails'
gem 'coffee-rails', '~> 4.0.1' # Master branch not OK with Rails 4, hence we point to branch that comply with Rails 4 by default
gem 'uglifier'
# Geocoding and locations
gem 'geocoder'
gem 'country-select'
group :production do
gem 'rails_12factor'
end
group :development do
gem 'quiet_assets' # mutes assets pipeline log messages
gem 'better_errors' # improve error pages
# retrieve binding of a method's caller in MRI 1.9.2+, only for debugging
gem 'binding_of_caller', platforms: [:mri_19, :rbx]
end
group :development, :test do
gem 'perftools.rb', require: 'perftools' # used to find tasks taking long time (ex when test are too long)
gem 'guard', '>=2.1.0'
gem 'guard-rspec'
gem 'guard-rails-assets'
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'pry-rails'
gem 'rspec-collection_matchers'
gem 'i18n-tasks'
end
group :test do
gem 'capybara'
gem 'selenium-webdriver' -ex: flash error messages...
gem 'capybara-webkit' -ex: flash error messages...
gem 'rb-inotify'
gem 'libnotify'
gem 'database_cleaner'
gem 'email_spec'
gem 'cucumber-rails', :require => false #
gem 'launchy'
gem 'shoulda-matchers'
gem 'minitest'
gem 'guard-zeus-client'
If you look in the source code of the sprockets gem (where the error is coming from) you can see that the error is being raised by these lines:
63 begin
64 if File.exist?(#path)
65 data = json_decode(File.read(#path))
66 end
67 rescue MultiJson::DecodeError => e
68 logger.error "#{#path} is invalid: #{e.class} #{e.message}"
69 end
Line 65 is the problem, specifically File.read(#path) - as shown by your error message (sprockets-2.12.3/lib/sprockets/manifest.rb:65:in `read').
Basically, #path is supposed to be a string representing a filename but it's actually pointing to a directory, which is causing File.read to fail. #path is supposed to be pointing to your asset's manifest file (usually created automatically by Sprockets) and I'm not sure why it's getting the incorrect path here - do you have anything that looks relevant to your manifest file in config/application.rb or in your environment config files? What about in app/assets/javascripts/application.js or app/assets/stylesheets/application.css?
Try editing your local copy of sprockets yourself (run "cd `bundle show sprockets`" from your app's directory to find it) and adding puts #path before line 65 above (just make sure you remember to remove it when you're done!) - what does it say?
Hmm... Is it possible that you have Sprocket and structure has been changed, or something like that?
Have you tried to remove that directory ( or just rename it )? This guy removed directory mentioned in error and it worked fine: Trying to install rails- EISDIR error .
There seems to be newer version, have you tried to update? (https://rubygems.org/gems/sprockets-rails)
NOTE: This should be comment but I don't have enough reputation for that...
Removing or commenting out this line of code in development.rb solves the problem:
config.assets.manifest = Rails.root.join("public/assets")
My mongoid.yml:
production:
sessions:
default:
database: kvallspressen_production
hosts:
- localhost:27017
options:
options:
development:
# Configure available database sessions. (required)
sessions:
# Defines the default session. (required)
default:
# Defines the name of the default database that Mongoid can connect to.
# (required).
database: kvallspressen_development
# Provides the hosts the default session can connect to. Must be an array
# of host:port pairs. (required)
hosts:
- localhost:27017
options:
# Change whether the session persists in safe mode by default.
# (default: false)
# safe: false
# Change the default consistency model to :eventual or :strong.
# :eventual will send reads to secondaries, :strong sends everything
# to master. (default: :eventual)
# consistency: :eventual
# How many times Moped should attempt to retry an operation after
# failure. (default: 30)
# max_retries: 30
# The time in seconds that Moped should wait before retrying an
# operation on failure. (default: 1)
# retry_interval: 1
# Configure Mongoid specific options. (optional)
options:
# Configuration for whether or not to allow access to fields that do
# not have a field definition on the model. (default: true)
# allow_dynamic_fields: true
# Enable the identity map, needed for eager loading. (default: false)
# identity_map_enabled: false
# Includes the root model name in json serialization. (default: false)
# include_root_in_json: false
# Include the _type field in serializaion. (default: false)
# include_type_for_serialization: false
# Preload all models in development, needed when models use
# inheritance. (default: false)
# preload_models: false
# Protect id and type from mass assignment. (default: true)
# protect_sensitive_fields: true
# Raise an error when performing a #find and the document is not found.
# (default: true)
# raise_not_found_error: true
# Raise an error when defining a scope with the same name as an
# existing method. (default: false)
# scope_overwrite_exception: false
# Skip the database version check, used when connecting to a db without
# admin access. (default: false)
# skip_version_check: false
# User Active Support's time zone in conversions. (default: true)
# use_activesupport_time_zone: true
# Ensure all times are UTC in the app side. (default: false)
# use_utc: false
test:
sessions:
default:
database: kvallspressen_test
hosts:
- localhost:27017
options:
consistency: :strong
# In the test environment we lower the retries and retry interval to
# low amounts for fast failures.
max_retries: 1
retry_interval: 0
When I run RAILS_ENV=production rake db:create
I receive this error:
** Invoke db:create (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
undefined method `has_key?' for nil:NilClass
/usr/local/lib/ruby/gems/2.0.0/gems/mongoid-3.0.23/lib/mongoid/config/validators/session.rb:99:in `no_database_or_uri?'
/usr/local/lib/ruby/gems/2.0.0/gems/mongoid-3.0.23/lib/mongoid/config/validators/session.rb:45:in `validate_session_database'
/usr/local/lib/ruby/gems/2.0.0/gems/mongoid-3.0.23/lib/mongoid/config/validators/session.rb:25:in `block in validate'
/usr/local/lib/ruby/gems/2.0.0/gems/mongoid-3.0.23/lib/mongoid/config/validators/session.rb:24:in `each_pair'
/usr/local/lib/ruby/gems/2.0.0/gems/mongoid-3.0.23/lib/mongoid/config/validators/session.rb:24:in `validate'
/usr/local/lib/ruby/gems/2.0.0/gems/mongoid-3.0.23/lib/mongoid/config.rb:183:in `sessions='
/usr/local/lib/ruby/gems/2.0.0/gems/mongoid-3.0.23/lib/mongoid/config.rb:213:in `load_configuration'
/usr/local/lib/ruby/gems/2.0.0/gems/mongoid-3.0.23/lib/mongoid/config.rb:85:in `load!'
/usr/local/lib/ruby/gems/2.0.0/gems/mongoid-3.0.23/lib/mongoid.rb:146:in `load!'
/usr/local/lib/ruby/gems/2.0.0/gems/mongoid-3.0.23/lib/mongoid/railtie.rb:67:in `block in <class:Railtie>'
/usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `instance_exec'
/usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `run'
/usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.12/lib/rails/initializable.rb:55:in `block in run_initializers'
/usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `each'
/usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `run_initializers'
/usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.12/lib/rails/application.rb:136:in `initialize!'
/usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
/var/www/kvallspressen/config/environment.rb:5:in `<top (required)>'
/usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.12/lib/rails/application.rb:103:in `require'
/usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.12/lib/rails/application.rb:103:in `require_environment!'
/usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.12/lib/rails/application.rb:297:in `block (2 levels) in initialize_tasks'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/task.rb:187:in `block in invoke_prerequisites'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/task.rb:185:in `each'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/task.rb:185:in `invoke_prerequisites'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/task.rb:165:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:23:in `load'
/usr/local/bin/rake:23:in `<main>'
Tasks: TOP => db:create => environment
Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.2.12'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem "less-rails", "~> 2.2.6"
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', :platforms => :ruby
gem "sass-rails", "~> 3.2.6"
gem "twitter-bootstrap-rails", '2.1.4'
gem 'bootstrap-sass', '~> 2.3.0.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
gem "mongoid", "~> 3.0.0"
I'm on Ubuntu 10.04.4 LTS, with rails 3.2.12, ruby 2.0.0p0 (2013-02-24 revision 39474) [i686-linux]
Just tested this on my local env. OSX 10.8.x and the same error appears.
What am I missing?
I just found this on the Mongoid home page:
db:create: Exists only for dependency purposes, does not actually do anything.
Therefore, when rake attempts to access your database (why it does this, I do not know), it throws an error because it doesn't exist.
Instead, mongoid provides this:
db:seed: Seeds the database from db/seeds.rb
db:setup: Creates indexes and seeds the database.
Therefore, your basic db setup should be defined in db/seeds.rb, and you can load it with
rake db:setup
I tried to follow this railscast to migrate my 3.0.10 rails app to 3.1.10, but things didn't go as smoothly for me as they did for Ryan. After working through some gemset dependency problems I now hit the following error when trying to launch the development server:
[nw0.0.1master (migrate_to_31)]$ rails s
=> Booting WEBrick
=> Rails 3.1.10 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.8.7/lib/rake.rb:2503:in `const_missing': uninitialized constant Sass::Plugin (NameError)
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:212:in `const_missing_from_s3_library'
from /Users/charlesweinberger/rails_projects/nw0.0.1master/config/initializers/active_admin.rb:2:in `<top (required)>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/engine.rb:556:in `block (2 levels) in <class:Engine>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/engine.rb:555:in `each'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/engine.rb:555:in `block in <class:Engine>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/initializable.rb:30:in `run'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/initializable.rb:54:in `each'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/application.rb:96:in `initialize!'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/charlesweinberger/rails_projects/nw0.0.1master/config/environment.rb:7:in `<top (required)>'
from /Users/charlesweinberger/rails_projects/nw0.0.1master/config.ru:3:in `block in <main>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rack-1.3.8/lib/rack/builder.rb:51:in `instance_eval'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rack-1.3.8/lib/rack/builder.rb:51:in `initialize'
from /Users/charlesweinberger/rails_projects/nw0.0.1master/config.ru:in `new'
from /Users/charlesweinberger/rails_projects/nw0.0.1master/config.ru:in `<main>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rack-1.3.8/lib/rack/builder.rb:40:in `eval'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rack-1.3.8/lib/rack/builder.rb:40:in `parse_file'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rack-1.3.8/lib/rack/server.rb:200:in `app'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/commands/server.rb:46:in `app'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rack-1.3.8/lib/rack/server.rb:304:in `wrapped_app'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rack-1.3.8/lib/rack/server.rb:254:in `start'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/commands/server.rb:70:in `start'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/commands.rb:54:in `block in <top (required)>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/commands.rb:49:in `tap'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/commands.rb:49:in `<top (required)>'
from script/rails:37:in `require'
from script/rails:37:in `<main>'
Here is my current Gemfile:
gem "pg"
gem 'pg_search'
gem 'rails', '3.1.10'
gem 'nokogiri', '1.5.5'
gem 'geocoder', '1.0.2'
gem 'devise', '1.5.3'
gem 'acts_as_api', '0.3.8'
gem 'paperclip', '~>2.4.1'
gem 'rake', '0.8.7'
gem 'omniauth', :git => 'https://github.com/intridea/omniauth.git'
gem 'fb_graph', '1.9.5'
gem 'twitter', :git => 'https://github.com/sferik/twitter.git'
gem 'jquery-rails', '>= 1.0.12'
gem 'aws-s3'
gem 'remotipart', '~> 1.0'
gem 'activeadmin'
gem 'formtastic', '~> 2.1.0'
gem "browser"
gem "httparty"
gem "thin"
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
end
group :production, :staging do
end
group :development do
gem 'rspec-rails'
gem 'annotate', '2.4.0'
gem 'faker', '0.3.1'
gem 'ruby-debug19', '0.11.6'
gem 'nifty-generators', '0.4.6'
gem 'silent-postgres'
end
group :test do
gem 'rspec'
gem 'webrat', '0.7.1'
gem 'factory_girl_rails'
gem "mocha", '0.9.12'
gem 'silent-postgres'
end
And, I've enabled the asset pipeline in application.rb. Here is application.rb:
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# If you precompile assets before deploying to production, use this line
Bundler.require *Rails.groups(:assets => %w(development test))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
module Nw001
class Application < Rails::Application
# Enable the asset pipeline
config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# JavaScript files you want as :defaults (application.js is always included).
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
# Use SQL instead of Active Record's schema dumper when creating the database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# Note, the migration that I use to install the unaccented module for pgs requires SQL
# config.active_record.schema_format = :sql
#uncomment to force ssl on localhost
# config.middleware.insert_before ActionDispatch::Static, "Rack::SSL"
end
end
And, made the suggested additions to my config/environments files.
Any idea how to get passed the uninitialized constant Sass::Plugin (NameError)???
I've also tried to use rails 3.1.0, which throws the same error. I also ran rails generate active_admin:assets to update the active_admin assets, but no love.
UPDATE
On the suggestion of #andrew I created a new sample rails3.1.10 application. Actually, what I did was delete my previous gemset for 3.1; create a new gemset using rvm; installed rails 3.1.10 into the new gemset; started using that new 3.1 gemset; and then created a new rails 3.1.10 app. The app ran as expected.
I then took things one step further by replacing the new apps gemfile with the gemfile from the app that I'm trying to migrate to 3.1.10. After working through a couple of dependency issues and reinserting the sqlite3 gem into the gemfile, again the new test app ran just as expected.
I then copied the test apps' gemfile back into the app that I'm trying to migrate and, still using the new 3.1 gemset, tried to load the development server. I still got an error, and it is similar to the error listed above, but it is somewhat different. Check it out:
[nw0.0.1master (master)]$ rails s
=> Booting WEBrick
=> Rails 3.1.10 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:212:in `const_missing_from_s3_library': uninitialized constant Sass::Plugin (NameError)
from /Users/charlesweinberger/rails_projects/nw0.0.1master/config/initializers/active_admin.rb:2:in `<top (required)>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/engine.rb:556:in `block (2 levels) in <class:Engine>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/engine.rb:555:in `each'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/engine.rb:555:in `block in <class:Engine>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/initializable.rb:30:in `run'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/initializable.rb:54:in `each'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/application.rb:96:in `initialize!'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/charlesweinberger/rails_projects/nw0.0.1master/config/environment.rb:7:in `<top (required)>'
from /Users/charlesweinberger/rails_projects/nw0.0.1master/config.ru:3:in `block in <main>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rack-1.3.8/lib/rack/builder.rb:51:in `instance_eval'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rack-1.3.8/lib/rack/builder.rb:51:in `initialize'
from /Users/charlesweinberger/rails_projects/nw0.0.1master/config.ru:in `new'
from /Users/charlesweinberger/rails_projects/nw0.0.1master/config.ru:in `<main>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rack-1.3.8/lib/rack/builder.rb:40:in `eval'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rack-1.3.8/lib/rack/builder.rb:40:in `parse_file'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rack-1.3.8/lib/rack/server.rb:200:in `app'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/commands/server.rb:46:in `app'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rack-1.3.8/lib/rack/server.rb:304:in `wrapped_app'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rack-1.3.8/lib/rack/server.rb:254:in `start'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/commands/server.rb:70:in `start'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/commands.rb:54:in `block in <top (required)>'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/commands.rb:49:in `tap'
from /Users/charlesweinberger/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.1.10/lib/rails/commands.rb:49:in `<top (required)>'
from script/rails:37:in `require'
from script/rails:37:in `<main>'
Does this new info trigger any ideas???
Thanks!
Problem was caused by me specifying gem 'rake', "0.8.7" in the gemfile. Changed it to gem 'rake', and that solved the problem. Note, you probably don't even need to include rake in the gemfile as it will be included as a dependency.