Connection refuse when sending mail with cron tab - ruby-on-rails

I'm doing a daily sending email task by using whenever gem.
I created a rake task in RAKEFILE name coffee. Here is my task's code:
task :coffee => :environment do
ReservationBooksNotify.notify.deliver
puts "hihi"
end
When I run this task in console
rake coffee, it worked!
But when I create a schedule in schedule.rb to automatically sending mail every minute, I get an error
hihi
rake aborted!
Connection refused - connect(2)
The error when I trace
rake coffee RAILS_ENV=production --trace
** Invoke coffee (first_time)
** Invoke environment (first_time)
** Invoke rails_admin:disable_initializer (first_time)
** Execute rails_admin:disable_initializer
[RailsAdmin] RailsAdmin initialization disabled by default. Pass SKIP_RAILS_ADMIN_INITIALIZER=false if you need it.
** Execute environment
** Execute coffee
rake aborted!
Connection refused - connect(2)
/home/duykhoa12t/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/smtp.rb:540:in `initialize'
/home/duykhoa12t/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/smtp.rb:540:in `open'
/home/duykhoa12t/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/smtp.rb:540:in `tcp_socket'
/home/duykhoa12t/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/smtp.rb:549:in `block in do_start'
/home/duykhoa12t/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/timeout.rb:68:in `timeout'
/home/duykhoa12t/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
/home/duykhoa12t/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/smtp.rb:549:in `do_start'
/home/duykhoa12t/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/smtp.rb:519:in `start'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/gems/mail-2.4.4/lib/mail/network/delivery_methods/smtp.rb:144:in `deliver!'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/gems/mail-2.4.4/lib/mail/message.rb:2034:in `do_delivery'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/gems/mail-2.4.4/lib/mail/message.rb:229:in `block in deliver'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/gems/actionmailer-3.2.8/lib/action_mailer/base.rb:415:in `block in deliver_mail'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/notifications.rb:123:in `block in instrument'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/notifications.rb:123:in `instrument'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/gems/actionmailer-3.2.8/lib/action_mailer/base.rb:413:in `deliver_mail'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/gems/mail-2.4.4/lib/mail/message.rb:229:in `deliver'
/home/duykhoa12t/Working/Bbookproject/Code/bbook/Rakefile:10:in `block in <top (required)>'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/duykhoa12t/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/bin/rake:19:in `load'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/bin/rake:19:in `<main>'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => coffee
My schedule.rb (in /config)
set :output, "~/Working/whenever.log"
every 2.minutes do
rake 'coffee'
end
I think my mailer configure has no problem because It worked when I send mail in controller and in console. Please help me, thanks!

Finally, I don't know why, I try rake assets: precompile, then restart server, everything works!

Related

Redmine receiving emails from imap

I have installed Redmine 2.6.1-stable, it works using apache2 and passenger.
I'm trying to receive emails using imap with this two rakes:
this one:
rake -f /opt/redmine-2.6.1/Rakefile --silent redmine:email:receive_imap RAILS_ENV="production" host=smtp.yandex.ru port=465 username=mail#yandex.ru password=pwd ssl=true project=desk folder=INBOX move_on_success=processed move_on_failure=failed no_permission_check=1 unknown_user=accept
And this one:
bundle exec rake redmine:email:receive_imap host='smtp.yandex.ru' username='mail#yandex.ru' password='pwd' port=465 ssl=true starttls=true allow_override=type,project project=desk
And this is log:
** Invoke redmine:email:receive_imap (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute redmine:email:receive_imap
rake aborted!
EOFError: end of file reached
/home/admin/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/imap.rb:1150:in `get_tagged_response'
/home/admin/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/imap.rb:1210:in `block in send_command'
/home/admin/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/home/admin/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/imap.rb:1192:in `send_command'
/home/admin/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/imap.rb:435:in `login'
/opt/redmine-2.6.1/lib/redmine/imap.rb:30:in `check'
/opt/redmine-2.6.1/lib/tasks/email.rake:128:in `block (4 levels) in <top (required)>'
/opt/redmine-2.6.1/app/models/mailer.rb:367:in `with_synched_deliveries'
/opt/redmine-2.6.1/lib/tasks/email.rake:127:in `block (3 levels) in <top (required)>'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/task.rb:240:in `call'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/task.rb:240:in `block in execute'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/task.rb:235:in `each'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/task.rb:235:in `execute'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/home/admin/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/task.rb:165:in `invoke'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/application.rb:150:in `invoke_task'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/application.rb:106:in `each'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/application.rb:106:in `block in top_level'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/application.rb:115:in `run_with_threads'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/application.rb:100:in `top_level'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/application.rb:78:in `block in run'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/application.rb:75:in `run'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/bin/rake:33:in `<top (required)>'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/bin/rake:23:in `load'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/bin/rake:23:in `<main>'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/bin/ruby_executable_hooks:15:in `eval'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => redmine:email:receive_imap
I can't understand what's going on.. Why it does not work properly?
Log /opt/redmine-2.6.1/logs/production.log is empty about this operation.
I recently solved my similar problem with enabling debug on IMAP, so I could see what's happened. To do that;
vim /var/www/redmine/lib/redmine/imap.rb
and after require 'net/imap' add this line:
Net::IMAP.debug = true
It usually relates to the login credentials/method.
You are trying to receive IMAP email from an SMTP server. These are completely different protocols.
Likely you want server imap.yandex.ru, Port 993, with SSL (not starttls).
Settings for IMAP appear to be available at https://yandex.com/support/mail/mail-clients.xml

Rails actionmailer SSL error hostname does not match server cert

I am running rails 4.2 and have set up a rake task to send an email but get this error when I run the rake task:
** Invoke send_report_email (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute send_report_email
production
rake aborted!
OpenSSL::SSL::SSLError: hostname "localhost" does not match the server certificate
/usr/lib/ruby/2.2.0/openssl/ssl.rb:240:in `post_connection_check'
/usr/lib/ruby/2.2.0/net/smtp.rb:588:in `tlsconnect'
/usr/lib/ruby/2.2.0/net/smtp.rb:563:in `do_start'
/usr/lib/ruby/2.2.0/net/smtp.rb:520:in `start'
/var/lib/gems/2.2.0/gems/mail-2.6.3/lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!'
/var/lib/gems/2.2.0/gems/mail-2.6.3/lib/mail/message.rb:252:in `deliver!'
/var/lib/gems/2.2.0/gems/actionmailer-4.2.3/lib/action_mailer/message_delivery.rb:77:in `deliver_now!'
/var/lib/gems/2.2.0/gems/actionmailer-4.2.3/lib/action_mailer/message_delivery.rb:95:in `deliver!'
/path/to/app/lib/tasks/email_tasks.rake:4:in `block in <top (required)>'
/usr/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/usr/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/usr/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/usr/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/usr/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/usr/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/usr/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/usr/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/usr/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/usr/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/usr/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/usr/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/usr/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/usr/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/usr/bin/rake:33:in `<main>'
Tasks: TOP => send_report_email
The line production is just me having a put ENV["RAILS_ENV"] in the rake task to make sure it is set to production
my /config/enviroments/production.rb
config.action_mailer_default_url_options = {host: "my.host.com"}
config.action_mailer_smtp_settings = {
enable_starttls_auto: false,
domain: 'my.host.com',
address: "my.host.com",
openssl_verify_mode: 'none'
}
When I ran apt-get install postfix I configured it also to use my.host.com and not localhost. Where is rails getting that localhost value from?

rake db:seed not working in dev - pg is running but the connection is being refused

I'm trying to follow along on this tutorial and can't get past the setup of pg.
https://shellycloud.com/blog/2013/10/adding-search-and-autocomplete-to-a-rails-app-with-elasticsearch
I set up pg on my computer using the postgres app, and I installed it successfully in my app using bundle install, but whenever I run rake db:seed I get the error below. pg is running on port 5432, I've tried uninstalling and installing again. rails server runs fine, and psql is working in the terminal.
I have been searching for hours and can't find anything that can explain what the issue is - most answers are to do with sunspot solr which I'm not using. I have already increased my system's shared memory as advised in the postgres app documentation:
sudo sysctl -w kern.sysv.shmall=65536
sudo sysctl -w kern.sysv.shmmax=16777216
I added the following to my development config as another answer mentioned this as a potential solution:
config.action_mailer.perform_deliveries = false
Any help would be very much appreciated!
This is the error I get when I run rake db:seed
michaels-air:bookstore_search michaeltaylor$ rake db:seed --trace
** Invoke db:seed (first_time)
** Execute db:seed
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
rake aborted!
Connection refused - connect(2)
/Users/michaeltaylor/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/net/http.rb:878:in `initialize'
/Users/michaeltaylor/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/net/http.rb:878:in `open'
/Users/michaeltaylor/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/net/http.rb:878:in `block in connect'
/Users/michaeltaylor/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
/Users/michaeltaylor/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/net/http.rb:877:in `connect'
/Users/michaeltaylor/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
/Users/michaeltaylor/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/net/http.rb:851:in `start'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rest-client-1.6.7/lib/restclient.rb:72:in `post'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/tire-0.6.0/lib/tire/http/client.rb:19:in `post'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/tire-0.6.0/lib/tire/index.rb:146:in `store'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/tire-0.6.0/lib/tire/model/search.rb:148:in `block in update_index'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:373:in `_run__4090249372457318285__update_elasticsearch_index__callbacks'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/tire-0.6.0/lib/tire/model/search.rb:144:in `update_index'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/tire-0.6.0/lib/tire/model/callbacks.rb:21:in `block in included'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:386:in `_run__4090249372457318285__save__callbacks'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/callbacks.rb:299:in `create_or_update'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/persistence.rb:106:in `save'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/validations.rb:51:in `save'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/attribute_methods/dirty.rb:32:in `save'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/transactions.rb:270:in `block (2 levels) in save'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/transactions.rb:326:in `block in with_transaction_returning_status'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/transactions.rb:209:in `transaction'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/transactions.rb:323:in `with_transaction_returning_status'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/transactions.rb:270:in `block in save'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/transactions.rb:281:in `rollback_active_record_state!'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/transactions.rb:269:in `save'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/persistence.rb:37:in `create'
/Users/michaeltaylor/Codes/bookstore_search/db/seeds.rb:19:in `block in <top (required)>'
/Users/michaeltaylor/Codes/bookstore_search/db/seeds.rb:18:in `each'
/Users/michaeltaylor/Codes/bookstore_search/db/seeds.rb:18:in `<top (required)>'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `block in load'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/engine.rb:540:in `load_seed'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/tasks/database_tasks.rb:153:in `load_seed'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:181:in `block (2 levels) in <top (required)>'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/michaeltaylor/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/bin/rake:23:in `load'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/bin/rake:23:in `<main>'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `eval'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:seed
This is my config yml
development:
adapter: postgresql
encoding: unicode
database: bookstore_development
pool: 5
username: michaeltaylor
password:
# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
# domain sockets, so uncomment these lines.
host: localhost
This is what I get if I try and run rake db:setup
michaels-air:bookstore_search michaeltaylor$ rake db:setup --trace
** Invoke db:setup (first_time)
** Invoke db:schema:load_if_ruby (first_time)
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:create
bookstore_development already exists
bookstore_test already exists
** Invoke environment (first_time)
** Execute environment
** Execute db:schema:load_if_ruby
** Invoke db:schema:load (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:schema:load
-- enable_extension("plpgsql")
-> 0.0194s
-- create_table("authors", {:force=>true})
-> 0.0214s
-- create_table("authors_books", {:force=>true})
-> 0.0075s
-- create_table("books", {:force=>true})
-> 0.0123s
-- create_table("books_subjects", {:force=>true})
-> 0.0082s
-- create_table("subjects", {:force=>true})
-> 0.0092s
-- initialize_schema_migrations_table()
-> 0.0029s
** Invoke db:structure:load_if_sql (first_time)
** Invoke db:create
** Invoke environment
** Execute db:structure:load_if_sql
** Invoke db:seed (first_time)
** Execute db:seed
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment
** Execute db:abort_if_pending_migrations
rake aborted!
Connection refused - connect(2)
/Users/michaeltaylor/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/net/http.rb:878:in `initialize'
/Users/michaeltaylor/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/net/http.rb:878:in `open'
/Users/michaeltaylor/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/net/http.rb:878:in `block in connect'
/Users/michaeltaylor/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
/Users/michaeltaylor/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/net/http.rb:877:in `connect'
/Users/michaeltaylor/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
/Users/michaeltaylor/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/net/http.rb:851:in `start'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rest-client-1.6.7/lib/restclient.rb:72:in `post'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/tire-0.6.0/lib/tire/http/client.rb:19:in `post'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/tire-0.6.0/lib/tire/index.rb:146:in `store'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/tire-0.6.0/lib/tire/model/search.rb:148:in `block in update_index'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:373:in `_run__1365093858615832810__update_elasticsearch_index__callbacks'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/tire-0.6.0/lib/tire/model/search.rb:144:in `update_index'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/tire-0.6.0/lib/tire/model/callbacks.rb:21:in `block in included'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:386:in `_run__1365093858615832810__save__callbacks'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/callbacks.rb:299:in `create_or_update'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/persistence.rb:106:in `save'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/validations.rb:51:in `save'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/attribute_methods/dirty.rb:32:in `save'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/transactions.rb:270:in `block (2 levels) in save'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/transactions.rb:326:in `block in with_transaction_returning_status'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/transactions.rb:209:in `transaction'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/transactions.rb:323:in `with_transaction_returning_status'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/transactions.rb:270:in `block in save'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/transactions.rb:281:in `rollback_active_record_state!'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/transactions.rb:269:in `save'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/persistence.rb:37:in `create'
/Users/michaeltaylor/Codes/bookstore_search/db/seeds.rb:19:in `block in <top (required)>'
/Users/michaeltaylor/Codes/bookstore_search/db/seeds.rb:18:in `each'
/Users/michaeltaylor/Codes/bookstore_search/db/seeds.rb:18:in `<top (required)>'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `block in load'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/engine.rb:540:in `load_seed'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/tasks/database_tasks.rb:153:in `load_seed'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:181:in `block (2 levels) in <top (required)>'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/michaeltaylor/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/task.rb:197:in `block in invoke_prerequisites'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/task.rb:195:in `each'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/task.rb:195:in `invoke_prerequisites'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/task.rb:174:in `block in invoke_with_call_chain'
/Users/michaeltaylor/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/bin/rake:23:in `load'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/bin/rake:23:in `<main>'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `eval'
/Users/michaeltaylor/.rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:setup => db:seed
Doesn't look like a Postgres issue. Judging by the stack trace, apparently you need to start your ElasticSearch server.

Rake Task to Restart Heroku Server

I'm trying to create a rake task that restarts my heroku servier. I've found this post, which has helped immensely: http://railspikes.com/2010/2/13/rake-task-for-deploying-to-heroku.
I've cobbled together this rake task, but it's giving me an error. The rake abouts and I get the message:
uninitialized constant Heroku::Command::BaseWithApp.
This is my method.
desc 'restarts the server'
task restart_server: :environment do
require 'heroku'
require 'heroku/command'
user, pass = File.read(File.expand_path("~/.heroku/credentials.txt")).split("\n")
heroku = Heroku::Client.new(user, pass)
cmd = Heroku::Command::BaseWithApp.new([])
remotes = cmd.git_remotes(File.dirname(__FILE__) + "/../..")
remote, app = remotes.detect {|key, value| value == (ENV['APP'])}# || cmd.app)}
if remote.nil?
raise "Could not find a git remote for the '#{ENV['APP']}' app"
end
heroku.restart(ENV['APP'])
end
I'm not sure why it's rejecting Heroku::Command. The app is already live on Heroku, so I know it's Heroku compliant.
Any advice?
EDIT: Here's my stack trace.
** Invoke restart_server (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute restart_server
rake aborted!
uninitialized constant Heroku::Command::BaseWithApp
/Users/bendowney/Sites/ProblemChildApp/lib/tasks/scheduler.rake:51:in `block in <top (required)>'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/bendowney/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/bin/rake:19:in `load'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/bin/rake:19:in `<main>'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#ProblemChildApp/bin/ruby_noexec_wrapper:14:in `eval'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#ProblemChildApp/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => restart_server

rake assets:precompile attempting to connect to database

I'm attempting to debug why my application is attempting to connect to my database when I run rake assets:precompile --trace.
I'm probably missing something in the stack trace...anyone see the pertinent line?
DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically. Please define instance methods directly in ActionController::Base instead. (called from <top (required)> at /Users/Kyle/Desktop/skateparks-web/config/application.rb:4)
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p290/bin/ruby /Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically. Please define instance methods directly in ActionController::Base instead. (called from <top (required)> at /Users/Kyle/Desktop/skateparks-web/config/application.rb:4)
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
rake aborted!
FATAL: database "skateparks_production" does not exist
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:1161:in `initialize'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:1161:in `new'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:1161:in `connect'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:316:in `initialize'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:27:in `new'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:27:in `postgresql_connection'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:277:in `new_connection'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:287:in `checkout_new_connection'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:235:in `block (2 levels) in checkout'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:230:in `loop'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:230:in `block in checkout'
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:229:in `checkout'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `connection'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `retrieve_connection'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activerecord-3.2.0/lib/active_record/model_schema.rb:308:in `clear_cache!'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activerecord-3.2.0/lib/active_record/railtie.rb:91:in `block (2 levels) in <class:Railtie>'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activesupport-3.2.0/lib/active_support/callbacks.rb:418:in `_run__2041913228368879189__prepare__1991931652306887621__callbacks'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activesupport-3.2.0/lib/active_support/callbacks.rb:405:in `__run_callback'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activesupport-3.2.0/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activesupport-3.2.0/lib/active_support/callbacks.rb:81:in `run_callbacks'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/actionpack-3.2.0/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/actionpack-3.2.0/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/railties-3.2.0/lib/rails/application/finisher.rb:48:in `block in <module:Finisher>'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/railties-3.2.0/lib/rails/initializable.rb:30:in `instance_exec'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/railties-3.2.0/lib/rails/initializable.rb:30:in `run'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/railties-3.2.0/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/railties-3.2.0/lib/rails/initializable.rb:54:in `each'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/railties-3.2.0/lib/rails/initializable.rb:54:in `run_initializers'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/railties-3.2.0/lib/rails/application.rb:136:in `initialize!'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/railties-3.2.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/Kyle/Desktop/skateparks-web/config/environment.rb:5:in `<top (required)>'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `require'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `block in require'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `require'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/railties-3.2.0/lib/rails/application.rb:103:in `require_environment!'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/railties-3.2.0/lib/rails/application.rb:292:in `block (2 levels) in initialize_tasks'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/actionpack-3.2.0/lib/sprockets/assets.rake:89:in `block (2 levels) in <top (required)>'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:174:in `each'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/actionpack-3.2.0/lib/sprockets/assets.rake:56:in `block (3 levels) in <top (required)>'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/application.rb:90:in `block (2 levels) in top_level'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/application.rb:90:in `block in top_level'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/bin/rake:19:in `load'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/bin/rake:19:in `<main>'
Tasks: TOP => environment
rake aborted!
Command failed with status (1): [/Users/Kyle/.rvm/rubies/ruby-1.9.2-p290/bi...]
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/file_utils.rb:45:in `call'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/file_utils.rb:45:in `sh'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/file_utils_ext.rb:36:in `sh'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/file_utils.rb:78:in `ruby'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/file_utils_ext.rb:36:in `ruby'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/actionpack-3.2.0/lib/sprockets/assets.rake:9:in `ruby_rake_task'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/actionpack-3.2.0/lib/sprockets/assets.rake:17:in `invoke_or_reboot_rake_task'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/actionpack-3.2.0/lib/sprockets/assets.rake:25:in `block (2 levels) in <top (required)>'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/application.rb:90:in `block (2 levels) in top_level'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/application.rb:90:in `block in top_level'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/bin/rake:19:in `load'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p290#skateparks/bin/rake:19:in `<main>'
Tasks: TOP => assets:precompile
rake assets:precompile initializes your app by default, which includes connection to the database.
Inside config/application.rb you can add this, but see the link below for warnings about it:
config.assets.initialize_on_precompile = false
Rails Guide on Precompiling Assets
I had that same problem. After updating Sprockets to version 3, whenever I tried to precompile the assets locally (development), however using the settings of the production environment, I had this error:
rake aborted!
Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add gem 'pg' to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
Because in my local (development) I use MySQL and in the server (production), I use Postgres.
The answer marked as resolved does not work for me, because config.assets.initialize_on_precompile is not available in Rails 4.2.1.
To solve, I followed 3 simple steps:
In your Gemfile, add: gem "activerecord-nulldb-adapter"
In database.yml, change the adapter as follow:
production:
adapter: <%= ENV['DB_ADAPTER'] ||= 'postgresql' %>
To compile your production assets locally. run in your terminal
DB_ADAPTER=nulldb RAILS_ENV=production rake assets:precompile
This solutions solved to me and I sawyed here.
Newer versions of Rails do not load the database during asset precompile. However, initializers will often cause it to load. This can be frustrating to debug, because the error omits the stack trace.
./bin/rails assets:precompile
(in ~/src/nautilus)
rake aborted!
ActiveRecord::NoDatabaseError: FATAL: database "your_app_development" does not exist
bundler: failed to load command: rake (~/src/your_app/vendor/bundle/ruby/2.6.0/bin/rake)
NoMethodError: undefined method `reject' for nil:NilClass
The less than helpful error.
So, how do we figure out where the problem is?
Move all the initializers out of config/initializers then run ./bin/rails assets:precompile.
If it works, great, you know the problem is in one of those files.
Move them back one by one till you find the offending file(s).
Now that the problem was found, how do we fix it?
Then when I find an initialilzer that has a problem I wrap it with the following check:
unless ARGV.include? "assets:precompile"
# ...
end
I prefer this over the nulldb because it reduces the number of dependencies I have to maintain in the app.
If it makes sense in your situation, you can choose against which environment assets:precompile should work, with the following command:
rake assets:precompile:all RAILS_ENV=development RAILS_GROUPS=assets
This make sense for my deployment because usually:
I make rake to generates assets on my development machine (because the memory of my vps is somehow limited)
I zip all the application with the assets generated in public/assets
I transfer the zip to the vps ans unzip the package there
Hope it helps.
Check your configuration files (in all environments). If for example
rake assets:precompile
works in development, but you are having issues in production
RAILS_ENV=production bundle exec rake assets:precompile
then you most likely have a reference to active record in your /config/environments/production.rb
config.active_record.dump_schema_after_migration = false
In order to avoid that altogether if you are planning on not taking advantage of active record or employing a NoSQL such as mongo, you may wish to initialize your new app as follows:
rails new myApp --skip-active-record
which is equivalent to -O (capital O) as far as I am concerned.
Maybe this won't work for all cases but I was able to avoid Rails attempting to connect to the database on the rake assets:* tasks by surrounding the code in some places with the snippet below on the /config/routes.rb:
unless defined?(::Rake::SprocketsTask)
devise_for ...
#...
end
devise_scope ...
#...
end
end
Sometimes code which depends on external services or environment variables will get loaded because of code on the initializer files which are not required for assets to be precompiled.
I've recently faced a similar issue and the responses above didn't work for me. I've found the file on config/initializers/ that was causing the issue and wrapped it with the following code:
unless defined?(::Rake::SprocketsTask)
#...
end
The snippet above will skip the code within it when running rake assets:precompile or others like rake assets:clean as well.
Hopefully this will help others in the future!

Resources