I followed all the docs for IronWorkerNG::Client.new and rails:
https://github.com/iron-io/iron_worker_rails_example
My .worker file is doing:
runtime 'ruby'
name 'CompanyList'
merge_gem 'activerecord'
merge_gem 'actionmailer'
merge_gem 'pg'
merge_gem 'aws-s3'
dir '../app/models'
file '../app/mailers/result_mailer.rb'
file "../app/views/result_mailer/email.html.erb", "result_mailer"
exec 'company_list.rb'
remote
and my ruby file does:
require 'action_mailer'
require 'active_record'
require 'aws/s3'
require 'pg'
require 'models/company_list.rb'
require 'result_mailer.rb'
puts "Starting CompanyList worker at #{Time.now}"
ActiveRecord::Base.establish_connection(params['database'])
mailer_config = params['mailer'].inject({}) { |memo, (k, v)| memo[k.to_sym] = v; memo }
#ActionMailer::Base.prepend_view_path('.')
ActionMailer::Base.view_paths = ['.']
ActionMailer::Base.smtp_settings = mailer_config
ActionMailer::Base.delivery_method = :smtp
But everytime I get this error:
/task/__gems__/gems/actionmailer-2.3.18/lib/action_mailer/base.rb:433:
in `method_missing': undefined method `email' for ResultMailer:Class
(NoMethodError)
from /task/models/company_list.rb:16:in `process_file'
from /task/company_list.rb:18:in `<top (required)>'
from /usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from __runner__.rb:213:in `<main>'
and ResultMailer DOES have an email method:
class ResultMailer < ActionMailer::Base
def email
to = 'andrew#testdomain.com'
mail :from => 'test#testdomain.com', :to => to, :subject => "Test"
end
end
any idea why action_mailer base line 433 is throwing that error? I can call ResultMailer.email.deliver from the console on my local system just fine. This error is on production with heroku and iron.io.
ah, sometimes writing out the question on stackoverflow makes you see the problem. I needed:
merge_gem "activerecord", "=3.2.8"
merge_gem 'actionmailer', '=3.2.8'
without the 3.2.8 version it was using an old old version of action mailer.
after uploading my app to git & heroku successfully , my app now does not work, when i run localhost:3000 get fails to connect message- . when i do rails s - i now get error messages
=> Booting WEBrick
=> Rails 3.2.12 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:469:in load': /Users/neilpatel/code/omrails/app/models/user.rb:12: syntax error, unexpected ':' (SyntaxError)
has_many :pins, :dependent => : destroy
^
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:469:inblock in load_file'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:639:in new_constants_in'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:468:inload_file'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:353:in require_or_load'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:502:inload_missing_constant'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:192:in block in const_missing'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:190:ineach'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:190:in const_missing'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:230:inblock in co
On line 12 of app/models/user.rb, instead of:
:dependent => : destroy
you should do:
:dependent => :destroy
Please try to understand what an error message actually says before asking a question.
I have some rspec test. For example
require 'spec_helper'
describe UsersController do
before (:each) do
#user = FactoryGirl.create(:user)
sign_in #user
end
describe "GET 'show'" do
it "should be successful" do
get :show, :id => #user.id
response.should be_success
end
it "should find the right user" do
get :show, :id => #user.id
assigns(:user).should == #user
end
end
end
When I run the rspec i get some errors
Failures:
1) UsersController GET 'show' should be successful
Failure/Error: #user = FactoryGirl.create(:user)
ActiveRecord::StatementInvalid:
SQLite3::SQLException: near "SAVEPOINT": syntax error: SAVEPOINT active_record_1
# ./spec/controllers/users_controller_spec.rb:6:in `block (2 levels) in <top (required)>'
2) UsersController GET 'show' should find the right user
Failure/Error: #user = FactoryGirl.create(:user)
ActiveRecord::StatementInvalid:
SQLite3::SQLException: near "SAVEPOINT": syntax error: SAVEPOINT active_record_1
# ./spec/controllers/users_controller_spec.rb:6:in `block (2 levels) in <top (required)>'
rspec ./spec/controllers/users_controller_spec.rb:12 # UsersController GET 'show' should be successful
rspec ./spec/controllers/users_controller_spec.rb:17 # UsersController GET 'show' should find the right user
What does the mean and what could be the problem with that rspec?
Host is CentOS5 and the included SQLite version is old and dont work with the sqlite3 gem.
So i had to config the bundler to use a newer installed sqlite version.
bundle config build.sqlite3 \
--with-sqlite3-include=/package/host/localhost/sqlite-3/include \
--with-sqlite3-lib=/package/host/localhost/sqlite-3/lib
Followed by a bundle install
Problem solved.
I'm begginer at Rails. I want to deploy my project at heroku.com. I use SqLite, but heroku doesn't support it. So, I try to move my project to MySQL. I did this instructions :Convert a Ruby on Rails app from sqlite to MySQL?
But, heroku says something like this: we're sorry, but something went wrong. Can you help me?
This is my gemfile:
source 'https://rubygems.org'
gem 'pg'
gem 'rails', '3.2.12'
gem 'gravatar_image_tag', '1.0.0.pre2'
gem "will_paginate", :git => "https://github.com/p7r/will_paginate.git", :branch => "rails3"
gem 'yaml_db', :git => 'git://github.com/ludicast/yaml_db.git'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development, :test do
gem 'faker', '0.3.1'
gem 'sqlite3-ruby', :require => 'sqlite3'
end
group :production do
gem "mysql2", "~> 0.3.11"
end
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
group :test do
gem 'rspec-rails', '2.6.1'
gem 'webrat', '0.7.1'
end
This is my database.yml file:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: myapp_development
pool: 5
username: root
password: "0761"
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: myapp_test
pool: 5
username: root
password: "0761"
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: myapp_production
pool: 5
username: root
password: "0761"
And here is my logs:
2013-03-26T13:11:32+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-03-26T13:11:32+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-03-26T13:11:37+00:00 heroku[web.1]: Stopping remaining processes with SIGKILL
2013-03-26T13:11:37+00:00 heroku[web.1]: Error R12 (Exit timeout) -> At least one process failed to exit within 10 seconds of SIGTERM
2013-03-26T13:11:38+00:00 app[web.1]: => Call with -d to detach
2013-03-26T13:11:38+00:00 app[web.1]: => Booting WEBrick
2013-03-26T13:11:38+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-03-26T13:11:38+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2013-03-26T13:11:38+00:00 app[web.1]: => Rails 3.2.12 application starting in production on http://0.0.0.0:33768
2013-03-26T13:11:39+00:00 app[web.1]: [2013-03-26 13:11:39] INFO WEBrick::HTTPServer#start: pid=2 port=33768
2013-03-26T13:11:39+00:00 app[web.1]: [2013-03-26 13:11:39] INFO ruby 1.9.2 (2011-07-09) [x86_64-linux]
2013-03-26T13:11:39+00:00 app[web.1]: [2013-03-26 13:11:39] INFO WEBrick 1.3.1
2013-03-26T13:11:39+00:00 heroku[web.1]: Process exited with status 137
2013-03-26T13:11:40+00:00 heroku[web.1]: State changed from starting to up
2013-03-26T13:11:59+00:00 app[web.1]: Started GET "/" for 46.72.99.61 at 2013-03-26 13:11:59 +0000
2013-03-26T13:11:59+00:00 app[web.1]: Processing by PagesController#home as HTML
2013-03-26T13:11:59+00:00 app[web.1]: Rendered pages/home.html.erb within layouts/application (8.8ms)
2013-03-26T13:11:59+00:00 app[web.1]: Rendered layouts/_stylesheets.html.erb (0.3ms)
2013-03-26T13:11:59+00:00 heroku[router]: at=info method=GET path=/ host=ancient-cliffs-5913.herokuapp.com fwd="46.72.99.61" dyno=web.1 queue=0 wait=0ms connect=3ms service=304ms status=500 bytes=643
2013-03-26T13:11:59+00:00 app[web.1]: Completed 500 Internal Server Error in 136ms
2013-03-26T13:11:59+00:00 app[web.1]:
2013-03-26T13:11:59+00:00 app[web.1]: Rendered layouts/_menu.html.erb (51.2ms)
2013-03-26T13:11:59+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR: relation "users" does not exist
2013-03-26T13:11:59+00:00 app[web.1]: LINE 5: WHERE a.attrelid = '"users"'::regclass
2013-03-26T13:11:59+00:00 app[web.1]: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2013-03-26T13:11:59+00:00 app[web.1]: ^
2013-03-26T13:11:59+00:00 app[web.1]: 6: <ul class="nav">
2013-03-26T13:11:59+00:00 app[web.1]: WHERE a.attrelid = '"users"'::regclass
2013-03-26T13:11:59+00:00 app[web.1]: ORDER BY a.attnum
2013-03-26T13:11:59+00:00 app[web.1]: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2013-03-26T13:11:59+00:00 app[web.1]: 8: <% if signed_in? %>
2013-03-26T13:11:59+00:00 app[web.1]: AND a.attnum > 0 AND NOT a.attisdropped
2013-03-26T13:11:59+00:00 app[web.1]: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2013-03-26T13:11:59+00:00 app[web.1]: FROM pg_attribute a LEFT JOIN pg_attrdef d
2013-03-26T13:11:59+00:00 app[web.1]: 11: <li><%= link_to "Заказ", "#" %></li>
2013-03-26T13:11:59+00:00 app[web.1]: app/models/user.rb:32:in `authenticate_with_salt'
2013-03-26T13:11:59+00:00 app[web.1]: ):
2013-03-26T13:11:59+00:00 app[web.1]: app/helpers/sessions_helper.rb:13:in `current_user'
2013-03-26T13:11:59+00:00 app[web.1]: app/helpers/sessions_helper.rb:17:in `signed_in?'
2013-03-26T13:11:59+00:00 app[web.1]: 9: <!--<li><%= link_to "Users", users_path %></li>-->
2013-03-26T13:11:59+00:00 app[web.1]: app/helpers/sessions_helper.rb:42:in `user_from_remember_token'
2013-03-26T13:11:59+00:00 app[web.1]: 7: <li class="active"><%= link_to "Главная", home_path %></li>
2013-03-26T13:11:59+00:00 app[web.1]: 5: <div class="nav-collapse collapse">
2013-03-26T13:11:59+00:00 app[web.1]:
2013-03-26T13:11:59+00:00 app[web.1]: app/views/layouts/application.html.erb:15:in `_app_views_layouts_application_html_erb__1283683624385357693_38228720'
2013-03-26T13:11:59+00:00 app[web.1]:
2013-03-26T13:11:59+00:00 app[web.1]: 10: <li><%= link_to "Меню", menu_path %></li>
2013-03-26T13:11:59+00:00 app[web.1]: app/views/layouts/_menu.html.erb:8:in `_app_views_layouts__menu_html_erb__3258341653661936969_33454780'
2013-03-26T13:12:00+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=ancient-cliffs-5913.herokuapp.com fwd="46.72.99.61" dyno=web.1 queue=0 wait=16ms connect=35ms service=33ms status=200 bytes=0
2013-03-26T13:25:17+00:00 heroku[slugc]: Slug compilation started
2013-03-26T13:25:50+00:00 heroku[api]: Release v14 created by nikskalkin#gmail.com
2013-03-26T13:25:50+00:00 heroku[api]: Deploy 7a646d5 by nikskalkin#gmail.com
2013-03-26T13:25:50+00:00 heroku[web.1]: State changed from up to starting
2013-03-26T13:25:51+00:00 heroku[slugc]: Slug compilation finished
2013-03-26T13:25:51+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 59776`
2013-03-26T13:25:55+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-03-26T13:25:55+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-03-26T13:25:57+00:00 app[web.1]: => Booting WEBrick
2013-03-26T13:25:57+00:00 app[web.1]: => Call with -d to detach
2013-03-26T13:25:57+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2013-03-26T13:25:57+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-03-26T13:25:57+00:00 app[web.1]: => Rails 3.2.12 application starting in production on http://0.0.0.0:59776
2013-03-26T13:25:57+00:00 app[web.1]: [2013-03-26 13:25:57] INFO ruby 1.9.2 (2011-07-09) [x86_64-linux]
2013-03-26T13:25:57+00:00 app[web.1]: [2013-03-26 13:25:57] INFO WEBrick::HTTPServer#start: pid=2 port=59776
2013-03-26T13:25:57+00:00 app[web.1]: [2013-03-26 13:25:57] INFO WEBrick 1.3.1
2013-03-26T13:25:58+00:00 heroku[web.1]: State changed from starting to up
2013-03-26T13:25:59+00:00 app[web.1]: Started GET "/" for 46.72.99.61 at 2013-03-26 13:25:59 +0000
2013-03-26T13:26:00+00:00 app[web.1]: Processing by PagesController#home as HTML
2013-03-26T13:26:00+00:00 app[web.1]: Rendered pages/home.html.erb within layouts/application (29.7ms)
2013-03-26T13:26:00+00:00 app[web.1]: Rendered layouts/_stylesheets.html.erb (0.3ms)
2013-03-26T13:26:00+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR: relation "users" does not exist
2013-03-26T13:26:00+00:00 app[web.1]: LINE 5: WHERE a.attrelid = '"users"'::regclass
2013-03-26T13:26:00+00:00 app[web.1]: ^
2013-03-26T13:26:00+00:00 app[web.1]: Rendered layouts/_menu.html.erb (26.4ms)
2013-03-26T13:26:00+00:00 app[web.1]: app/helpers/sessions_helper.rb:42:in `user_from_remember_token'
2013-03-26T13:26:00+00:00 app[web.1]: app/models/user.rb:32:in `authenticate_with_salt'
2013-03-26T13:26:00+00:00 app[web.1]: app/views/layouts/application.html.erb:15:in `_app_views_layouts_application_html_erb__3050356598751074094_29958360'
2013-03-26T13:26:00+00:00 app[web.1]: Completed 500 Internal Server Error in 99ms
2013-03-26T13:26:00+00:00 app[web.1]: 9: <!--<li><%= link_to "Users", users_path %></li>-->
2013-03-26T13:26:00+00:00 app[web.1]: app/views/layouts/_menu.html.erb:8:in `_app_views_layouts__menu_html_erb___3316497000915670487_28099760'
2013-03-26T13:26:00+00:00 app[web.1]: 6: <ul class="nav">
2013-03-26T13:26:00+00:00 app[web.1]: 7: <li class="active"><%= link_to "Главная", home_path %></li>
2013-03-26T13:26:00+00:00 app[web.1]: app/helpers/sessions_helper.rb:17:in `signed_in?'
2013-03-26T13:26:00+00:00 app[web.1]: WHERE a.attrelid = '"users"'::regclass
2013-03-26T13:26:00+00:00 app[web.1]:
2013-03-26T13:26:00+00:00 app[web.1]: 5: <div class="nav-collapse collapse">
2013-03-26T13:26:00+00:00 app[web.1]: 11: <li><%= link_to "Заказ", "#" %></li>
2013-03-26T13:26:00+00:00 app[web.1]:
2013-03-26T13:26:00+00:00 app[web.1]:
2013-03-26T13:26:00+00:00 app[web.1]: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2013-03-26T13:26:00+00:00 app[web.1]: 10: <li><%= link_to "Меню", menu_path %></li>
2013-03-26T13:26:00+00:00 app[web.1]: FROM pg_attribute a LEFT JOIN pg_attrdef d
2013-03-26T13:26:00+00:00 app[web.1]: 8: <% if signed_in? %>
2013-03-26T13:26:00+00:00 app[web.1]: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2013-03-26T13:26:00+00:00 app[web.1]: AND a.attnum > 0 AND NOT a.attisdropped
2013-03-26T13:26:00+00:00 app[web.1]: app/helpers/sessions_helper.rb:13:in `current_user'
2013-03-26T13:26:00+00:00 app[web.1]: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2013-03-26T13:26:00+00:00 app[web.1]: ORDER BY a.attnum
2013-03-26T13:26:00+00:00 app[web.1]: ):
2013-03-26T13:26:00+00:00 heroku[router]: at=info method=GET path=/ host=ancient-cliffs-5913.herokuapp.com fwd="46.72.99.61" dyno=web.1 queue=0 wait=0ms connect=1ms service=254ms status=500 bytes=643
2013-03-26T13:26:00+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=ancient-cliffs-5913.herokuapp.com fwd="46.72.99.61" dyno=web.1 queue=0 wait=0ms connect=3ms service=31ms status=200 bytes=0
root#Nikita-PC:/home/nikita/rails/invent# heroku open
Opening ancient-cliffs-5913... done
root#Nikita-PC:/home/nikita/rails/invent# heroku logs
2013-03-26T13:11:59+00:00 app[web.1]: 7: <li class="active"><%= link_to "Главная", home_path %></li>
2013-03-26T13:11:59+00:00 app[web.1]: 5: <div class="nav-collapse collapse">
2013-03-26T13:11:59+00:00 app[web.1]:
2013-03-26T13:11:59+00:00 app[web.1]: app/views/layouts/application.html.erb:15:in `_app_views_layouts_application_html_erb__1283683624385357693_38228720'
2013-03-26T13:11:59+00:00 app[web.1]:
2013-03-26T13:11:59+00:00 app[web.1]: 10: <li><%= link_to "Меню", menu_path %></li>
2013-03-26T13:11:59+00:00 app[web.1]: app/views/layouts/_menu.html.erb:8:in `_app_views_layouts__menu_html_erb__3258341653661936969_33454780'
2013-03-26T13:12:00+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=ancient-cliffs-5913.herokuapp.com fwd="46.72.99.61" dyno=web.1 queue=0 wait=16ms connect=35ms service=33ms status=200 bytes=0
2013-03-26T13:25:17+00:00 heroku[slugc]: Slug compilation started
2013-03-26T13:25:50+00:00 heroku[api]: Release v14 created by nikskalkin#gmail.com
2013-03-26T13:25:50+00:00 heroku[api]: Deploy 7a646d5 by nikskalkin#gmail.com
2013-03-26T13:25:50+00:00 heroku[web.1]: State changed from up to starting
2013-03-26T13:25:51+00:00 heroku[slugc]: Slug compilation finished
2013-03-26T13:25:51+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 59776`
2013-03-26T13:25:55+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-03-26T13:25:55+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-03-26T13:25:57+00:00 app[web.1]: => Booting WEBrick
2013-03-26T13:25:57+00:00 app[web.1]: => Call with -d to detach
2013-03-26T13:25:57+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2013-03-26T13:25:57+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-03-26T13:25:57+00:00 app[web.1]: => Rails 3.2.12 application starting in production on http://0.0.0.0:59776
2013-03-26T13:25:57+00:00 app[web.1]: [2013-03-26 13:25:57] INFO ruby 1.9.2 (2011-07-09) [x86_64-linux]
2013-03-26T13:25:57+00:00 app[web.1]: [2013-03-26 13:25:57] INFO WEBrick::HTTPServer#start: pid=2 port=59776
2013-03-26T13:25:57+00:00 app[web.1]: [2013-03-26 13:25:57] INFO WEBrick 1.3.1
2013-03-26T13:25:58+00:00 heroku[web.1]: State changed from starting to up
2013-03-26T13:25:59+00:00 app[web.1]: Started GET "/" for 46.72.99.61 at 2013-03-26 13:25:59 +0000
2013-03-26T13:26:00+00:00 app[web.1]: Processing by PagesController#home as HTML
2013-03-26T13:26:00+00:00 app[web.1]: Rendered pages/home.html.erb within layouts/application (29.7ms)
2013-03-26T13:26:00+00:00 app[web.1]: Rendered layouts/_stylesheets.html.erb (0.3ms)
2013-03-26T13:26:00+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR: relation "users" does not exist
2013-03-26T13:26:00+00:00 app[web.1]: LINE 5: WHERE a.attrelid = '"users"'::regclass
2013-03-26T13:26:00+00:00 app[web.1]: ^
2013-03-26T13:26:00+00:00 app[web.1]: Rendered layouts/_menu.html.erb (26.4ms)
2013-03-26T13:26:00+00:00 app[web.1]: app/helpers/sessions_helper.rb:42:in `user_from_remember_token'
2013-03-26T13:26:00+00:00 app[web.1]: app/models/user.rb:32:in `authenticate_with_salt'
2013-03-26T13:26:00+00:00 app[web.1]: app/views/layouts/application.html.erb:15:in `_app_views_layouts_application_html_erb__3050356598751074094_29958360'
2013-03-26T13:26:00+00:00 app[web.1]: Completed 500 Internal Server Error in 99ms
2013-03-26T13:26:00+00:00 app[web.1]: 9: <!--<li><%= link_to "Users", users_path %></li>-->
2013-03-26T13:26:00+00:00 app[web.1]: app/views/layouts/_menu.html.erb:8:in `_app_views_layouts__menu_html_erb___3316497000915670487_28099760'
2013-03-26T13:26:00+00:00 app[web.1]: 6: <ul class="nav">
2013-03-26T13:26:00+00:00 app[web.1]: 7: <li class="active"><%= link_to "Главная", home_path %></li>
2013-03-26T13:26:00+00:00 app[web.1]: app/helpers/sessions_helper.rb:17:in `signed_in?'
2013-03-26T13:26:00+00:00 app[web.1]: WHERE a.attrelid = '"users"'::regclass
2013-03-26T13:26:00+00:00 app[web.1]:
2013-03-26T13:26:00+00:00 app[web.1]: 5: <div class="nav-collapse collapse">
2013-03-26T13:26:00+00:00 app[web.1]: 11: <li><%= link_to "Заказ", "#" %></li>
2013-03-26T13:26:00+00:00 app[web.1]:
2013-03-26T13:26:00+00:00 app[web.1]:
2013-03-26T13:26:00+00:00 app[web.1]: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2013-03-26T13:26:00+00:00 app[web.1]: 10: <li><%= link_to "Меню", menu_path %></li>
2013-03-26T13:26:00+00:00 app[web.1]: FROM pg_attribute a LEFT JOIN pg_attrdef d
2013-03-26T13:26:00+00:00 app[web.1]: 8: <% if signed_in? %>
2013-03-26T13:26:00+00:00 app[web.1]: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2013-03-26T13:26:00+00:00 app[web.1]: AND a.attnum > 0 AND NOT a.attisdropped
2013-03-26T13:26:00+00:00 app[web.1]: app/helpers/sessions_helper.rb:13:in `current_user'
2013-03-26T13:26:00+00:00 app[web.1]: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2013-03-26T13:26:00+00:00 app[web.1]: ORDER BY a.attnum
2013-03-26T13:26:00+00:00 app[web.1]: ):
2013-03-26T13:26:00+00:00 heroku[router]: at=info method=GET path=/ host=ancient-cliffs-5913.herokuapp.com fwd="46.72.99.61" dyno=web.1 queue=0 wait=0ms connect=1ms service=254ms status=500 bytes=643
2013-03-26T13:26:00+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=ancient-cliffs-5913.herokuapp.com fwd="46.72.99.61" dyno=web.1 queue=0 wait=0ms connect=3ms service=31ms status=200 bytes=0
2013-03-26T13:25:53+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2013-03-26T13:25:54+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/webrick/server.rb:90:in `select'
2013-03-26T13:25:54+00:00 app[web.1]: [2013-03-26 13:25:54] ERROR SignalException: SIGTERM
2013-03-26T13:26:04+00:00 heroku[web.1]: Stopping remaining processes with SIGKILL
2013-03-26T13:26:04+00:00 heroku[web.1]: Error R12 (Exit timeout) -> At least one process failed to exit within 10 seconds of SIGTERM
2013-03-26T13:26:06+00:00 heroku[web.1]: Process exited with status 137
2013-03-26T13:29:30+00:00 app[web.1]: Started GET "/" for 46.72.99.61 at 2013-03-26 13:29:30 +0000
2013-03-26T13:29:30+00:00 app[web.1]: Rendered layouts/_stylesheets.html.erb (0.0ms)
2013-03-26T13:29:30+00:00 app[web.1]: Processing by PagesController#home as HTML
2013-03-26T13:29:30+00:00 app[web.1]: Rendered pages/home.html.erb within layouts/application (0.0ms)
2013-03-26T13:29:30+00:00 app[web.1]: LINE 5: WHERE a.attrelid = '"users"'::regclass
2013-03-26T13:29:30+00:00 app[web.1]: ^
2013-03-26T13:29:30+00:00 app[web.1]: Rendered layouts/_menu.html.erb (6.5ms)
2013-03-26T13:29:30+00:00 app[web.1]: Completed 500 Internal Server Error in 13ms
2013-03-26T13:29:30+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR: relation "users" does not exist
2013-03-26T13:29:30+00:00 app[web.1]:
2013-03-26T13:29:30+00:00 app[web.1]: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2013-03-26T13:29:30+00:00 app[web.1]: WHERE a.attrelid = '"users"'::regclass
2013-03-26T13:29:30+00:00 app[web.1]: FROM pg_attribute a LEFT JOIN pg_attrdef d
2013-03-26T13:29:30+00:00 app[web.1]: AND a.attnum > 0 AND NOT a.attisdropped
2013-03-26T13:29:30+00:00 app[web.1]: ORDER BY a.attnum
2013-03-26T13:29:30+00:00 app[web.1]: ):
2013-03-26T13:29:30+00:00 app[web.1]: 6: <ul class="nav">
2013-03-26T13:29:30+00:00 app[web.1]: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2013-03-26T13:29:30+00:00 app[web.1]: 5: <div class="nav-collapse collapse">
2013-03-26T13:29:30+00:00 app[web.1]: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2013-03-26T13:29:30+00:00 app[web.1]: 10: <li><%= link_to "Меню", menu_path %></li>
2013-03-26T13:29:30+00:00 app[web.1]: 9: <!--<li><%= link_to "Users", users_path %></li>-->
2013-03-26T13:29:30+00:00 app[web.1]: 11: <li><%= link_to "Заказ", "#" %></li>
2013-03-26T13:29:30+00:00 app[web.1]: app/models/user.rb:32:in `authenticate_with_salt'
2013-03-26T13:29:30+00:00 app[web.1]: app/helpers/sessions_helper.rb:13:in `current_user'
2013-03-26T13:29:30+00:00 app[web.1]: app/helpers/sessions_helper.rb:17:in `signed_in?'
2013-03-26T13:29:30+00:00 app[web.1]: 8: <% if signed_in? %>
2013-03-26T13:29:30+00:00 app[web.1]: app/helpers/sessions_helper.rb:42:in `user_from_remember_token'
2013-03-26T13:29:30+00:00 app[web.1]: 7: <li class="active"><%= link_to "Главная", home_path %></li>
2013-03-26T13:29:30+00:00 app[web.1]:
2013-03-26T13:29:30+00:00 app[web.1]:
2013-03-26T13:29:30+00:00 app[web.1]: app/views/layouts/application.html.erb:15:in `_app_views_layouts_application_html_erb__3050356598751074094_29958360'
2013-03-26T13:29:30+00:00 app[web.1]: app/views/layouts/_menu.html.erb:8:in `_app_views_layouts__menu_html_erb___3316497000915670487_28099760'
2013-03-26T13:29:30+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=ancient-cliffs-5913.herokuapp.com fwd="46.72.99.61" dyno=web.1 connect=10ms service=9ms status=304 bytes=0
2013-03-26T13:29:30+00:00 heroku[router]: at=info method=GET path=/ host=ancient-cliffs-5913.herokuapp.com fwd="46.72.99.61" dyno=web.1 queue=0 wait=0ms connect=1ms service=34ms status=500 bytes=643
Update
I can use only MySQL. My project is testing task for internship of one company i'm looking for. And they said me to use MySql in project.
Heroku is really designed to run PostgreSQL as its database engine, not MySQL. You actually have the postgresql gem installed (pg). The error you're getting is related to accessing the database (specifically the users table).
While it is possible to run MySQL on Heroku as a new user I'd recommend just working with postgresql instead, as it's much easier to set up and you won't have to worry about installing additional add-ons to get it to work.
Where are you hosting your MySQL database? Make sure you db server has allowed remote access from Heroku. Amazon (AWS) is best solution once setup properly.
If you are hosting the MySQL db on your local machine for production then you will need to make sure Heroku's servers have remote access back to your computer for production.
In your Gemfile remove these lines and replace with example below.
gem 'pg'
gem 'sqlite3-ruby', :require => 'sqlite3'
gem "mysql2", "~> 0.3.11"
I also would strongly recomend checking out https://github.com/laserlemon/figaro & http://railscasts.com/episodes/85-yaml-configuration-revised?view=comments
To Setup MySQL on AWS:
Update Gemfile with correct db gems
Update database.yml connection settings
Install Heroku toolbelt https://toolbelt.heroku.com/
Sign up for AWS hosted MySQL http://aws.amazon.com/rds/
Amazon requires you to grant access from both your local machine’s WAN IP & you will also need to grant Heroku’s application servers authorized access for production.
SignIn to AWS via http://console.aws.amazon.com/
Go to "Services" > "RDS"
Under left menu "Navigation/Databases" > "DB Security Groups" > "default"
Add CIDR/IP: #.#.#.# (your local pc ip http://www.whatsmyip.us/)
Add EC2 Security Group (this is heroku aws id)
aws account id: "098166147350"
ec2 security group: "default"
Setup AWS RDS MySQL Database on Heroku
Confirm Heroku is Granted AWS RDS Remote Access
$ cd myAppDir
$ heroku login
$ heroku config:get DATABASE_URL
$ heroku addons:add amazon_rds url=mysql2://masteruser:pass#dbinstance.123endpoint321.amazonaws.com/databasename
$ heroku config:get DATABASE_URL
Confirm New Database Settings
Gemfile ~ Don't forget $ bundle install & $ bundle update
# ===~===~===~===~===~===~===~===~===~===
group :development do
gem 'mysql2'
end
# ===~===~===~===~===~===~===~===~===~===
group :production do
# gem 'pg'
gem 'mysql2'
end
# ===~===~===~===~===~===~===~===~===~===
group :test do
gem 'sqlite3'
# gem 'mysql2'
end
# ===~===~===~===~===~===~===~===~===~===
database.yml ~ Examples of each type of db connection.
# AWS RDS ~~~~~~~~~~~~~~~~
development:
adapter: mysql2
encoding: utf8
host: dbinstance.123endpoint789.us-east-1.rds.amazonaws.com
database: appdb_dev
pool: 5
username: masterusername
password: password
socket: /tmp/mysql.sock
# ~~~~~~~~~~~~~~~~~~~~~~~~
# MySQL localhost ~~~~~~~~
# development:
# adapter: mysql2
# encoding: utf8
# database: erics_rails_app_dev
# pool: 5
# username: root
# password:
# socket: /tmp/mysql.sock
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# HEROKU ~~~~~~~~~~~~~~~~~
# Note: On Heroku production this (over)written on deployment.
production:
adapter: pg
database: localhost
timeout: 5000
# ORIGINAL TEST ~~~~~~~~~~~~~~~
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
MySQL WorkBench Settings ~ http://dev.mysql.com/downloads/workbench/
* hostname = dbinstance.123endpoint789.us-east-1.rds.amazonaws.com
* user = masterusername
* pass = password
* port = 3306
Do you have a mysql addon for the app?
Heroku provides you with a Postgres database by default but if you want to use another database type aka mysql then you will need to use an addon. There may be a free solution in the addons i'm not sure.
When you deploy your application to Heroku they override your database.yml file pointing it to the correct database url.
First heroku provides you a PostgreSQL database for your app, edit your Gemfile
and add gem 'pg'
also it uses thin as server so add
gem 'thin'
chage your Database.yml as for all enviromments
adapter: PostgreSQL
encoding: utf8
reconnect: false
database: myapp_production
pool: 5
username: root
password: "0761"
Remove the mysql gem from your production environment. Heroku doesn't support sqlite databases. Use postgres in production. Your gemfile should look something like this:
group :production do
gem "pg" # move your pg gem inside here
end
group :development, :test do
gem "sqlite3"
end
Change your gemfile to reflect the above, run $ bundle to bundle then new gems, add and commit your changes and push them to heroku.
This will allow you to use sqlite in development and test, and postgresql in production, which heroku requires.
I just installed a Rails 3.1 app to my deployment server.
When I tried to run
sudo rake db:setup RAILS_ENV=“production”
I got an error message saying
rake aborted!
undefined method `[]' for nil:NilClass
With --trace it says:
** Invoke db:setup (first_time)
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:create
rake aborted!
undefined method '[]' for nil:NilClass
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.1.0/lib/active_record/railties/databases.rake:74:in 'rescue in create_database'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.1.0/lib/active_record/railties/databases.rake:54:in 'create_database'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.1.0/lib/active_record/railties/databases.rake:44:in 'block (2 levels) in <top (required)>'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:205:in 'call'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:205:in 'block in execute'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:200:in 'each'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:200:in 'execute'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:158:in 'block in invoke_with_call_chain'
/usr/local/lib/ruby/1.9.1/monitor.rb:201:in 'mon_synchronize'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:151:in 'invoke_with_call_chain'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:176:in 'block in invoke_prerequisites'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:174:in 'each'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:174:in 'invoke_prerequisites'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:157:in 'block in invoke_with_call_chain'
/usr/local/lib/ruby/1.9.1/monitor.rb:201:in 'mon_synchronize'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:151:in 'invoke_with_call_chain'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:144:in 'invoke'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:112:in 'invoke_task'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:in 'block (2 levels) in top_level'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:in 'each'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:in 'block in top_level'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:129:in 'standard_exception_handling'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:84:in 'top_level'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:62:in 'block in run'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:129:in 'standard_exception_handling'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:59:in 'run'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/bin/rake:32:in '<top (required)>'
/usr/local/bin/rake:19:in 'load'
/usr/local/bin/rake:19:in '<main>'
Tasks: TOP => db:setup => db:create
My database.yml says
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: t_production
pool: 5
username: deploy
password: V
host: localhost
There is only 1 migration and it says this:
class CreateDeals < ActiveRecord::Migration
def change
create_table :deals do |t|
t.string :title
t.text :description
t.string :image_url
t.decimal :price, :precision => 8, :scale => 2
t.timestamps
end
end
end
What should I try to fix this? I'm not even sure where to begin.
You should fix your statement, the double quotes are wrong. They need to be regular " quotes. It probably tries to load a setting for the “production” environment, which obviously doesn't exist.
If you are using the correct quotes, make sure your identation is correct, the definition should look something like the following:
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: t_production
pool: 5
username: deploy
password: V
host: localhost