How to resolve error regarding on MySQL in ROR - mysql

Can anybody help me to solve the following error ?When i typed rake db:create on cmd i got these errors.
Error:
rake aborted!
NoMethodError: undefined method `each' for #<String:0x1a1af20>
Tasks: TOP => db:create => db:load_config
(See full trace by running task with --trace)
When i run rake db:create --trace i got the following traces.
rake aborted!
NoMethodError: undefined method `each' for #
Tasks: TOP => db:create => db:load_config
(See full trace by running task with --trace)
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
rake aborted!
NoMethodError: undefined method `each' for #<String:0x1a37888>
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0/lib/active_record/connect
ion_adapters/connection_specification.rb:150:in `resolve_all'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0/lib/active_record/connect
ion_handling.rb:69:in `resolve'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0/lib/active_record/core.rb
:46:in `configurations='
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0/lib/active_record/railtie
s/databases.rake:5:in `block (2 levels) in <top (required)>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:240:in `block i
n execute'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute
'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:179:in `block i
n invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_
with_call_chain'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:201:in `block i
n invoke_prerequisites'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:199:in `each'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:199:in `invoke_
prerequisites'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:178:in `block i
n invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_
with_call_chain'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:150:in `
invoke_task'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:106:in `
block (2 levels) in top_level'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:106:in `
each'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:106:in `
block in top_level'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:115:in `
run_with_threads'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:100:in `
top_level'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:78:in `b
lock in run'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:176:in `
standard_exception_handling'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:75:in `r
un'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.4.2/bin/rake:33:in `<top (required)>
'
C:/Ruby193/bin/rake:23:in `load'
C:/Ruby193/bin/rake:23:in `<main>'
Tasks: TOP => db:create => db:load_config
My database.yml file is described below.
default:&default
adapter:mysql2
encoding:utf8
pool:5
username:root
password:pass
host:localhost
development:<<:*default
database:sqlbook_development
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:<<:*default
database:sqlbook_test
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="mysql2://myuser:mypass#localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
#
production:<<:*default
database:sqlbook_production
username:sqlbook
password:pass
I am using rails version 4.2.0 and ruby 1.9.3.Please help me to resolve this error.Thanks in advance..

Related

Chromedriver / Capybara Too many open files - socket(2) for "127.0.0.1" port 9518

I'm getting this error (details below) when a capybara selector is malformed or can't find. Why is it happening, and how can I prevent the error?
This is new, I think, since our recent upgrade to the latest driver.
The command that triggers this:
find('.panel.#synopsis .btn', text: /new email/i)
Before such an error sudo lsof -i :9518 returns 6 items, after there seem to be hundreds of these.
Error:
Failure/Error: TCPSocket.open(conn_addr, conn_port, #local_host, #local_port)
Errno::EMFILE:
Failed to open TCP connection to 127.0.0.1:9518 (Too many open files - socket(2) for "127.0.0.1" port 9518)
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/2.7.0/net/http.rb:960:in `initialize'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/2.7.0/net/http.rb:960:in `open'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/2.7.0/net/http.rb:960:in `block in connect'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/2.7.0/timeout.rb:78:in `timeout'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/2.7.0/net/http.rb:958:in `connect'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/2.7.0/net/http.rb:943:in `do_start'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/webmock-3.7.6/lib/webmock/http_lib_adapters/net_http.rb:136:in `start_with_connect_without_finish'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/webmock-3.7.6/lib/webmock/http_lib_adapters/net_http.rb:104:in `request'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/default.rb:129:in `response_for'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/default.rb:82:in `request'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/common.rb:64:in `call'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/bridge.rb:167:in `execute'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/w3c/bridge.rb:567:in `execute'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/w3c/bridge.rb:173:in `window_handles'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/driver.rb:187:in `window_handles'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/capybara-3.30.0/lib/capybara/selenium/driver.rb:208:in `window_handles'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/capybara-3.30.0/lib/capybara/selenium/driver_specializations/chrome_driver.rb:43:in `reset!'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/capybara-3.30.0/lib/capybara/session.rb:130:in `reset!'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/capybara-3.30.0/lib/capybara.rb:322:in `block in reset_sessions!'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/capybara-3.30.0/lib/capybara.rb:322:in `reverse_each'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/capybara-3.30.0/lib/capybara.rb:322:in `reset_sessions!'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/capybara-3.30.0/lib/capybara/rspec.rb:18:in `block (2 levels) in <top (required)>'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example.rb:450:in `instance_exec'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example.rb:450:in `instance_exec'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/hooks.rb:363:in `run'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/hooks.rb:515:in `block in run_owned_hooks_for'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/hooks.rb:514:in `each'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/hooks.rb:514:in `run_owned_hooks_for'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/hooks.rb:601:in `block in run_example_hooks_for'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/hooks.rb:600:in `each'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/hooks.rb:600:in `run_example_hooks_for'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/hooks.rb:471:in `run'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example.rb:510:in `run_after_example'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example.rb:276:in `block in run'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example.rb:503:in `block in with_around_and_singleton_context_hooks'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example.rb:460:in `block in with_around_example_hooks'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/hooks.rb:472:in `block in run'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/hooks.rb:612:in `block in run_around_example_hooks_for'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example.rb:345:in `call'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-rails-3.9.0/lib/rspec/rails/adapters.rb:127:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example.rb:450:in `instance_exec'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example.rb:450:in `instance_exec'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/hooks.rb:381:in `execute_with'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/hooks.rb:614:in `block (2 levels) in run_around_example_hooks_for'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example.rb:345:in `call'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/hooks.rb:615:in `run_around_example_hooks_for'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/hooks.rb:472:in `run'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example.rb:460:in `with_around_example_hooks'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example.rb:503:in `with_around_and_singleton_context_hooks'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example.rb:254:in `run'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example_group.rb:633:in `block in run_examples'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example_group.rb:629:in `map'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example_group.rb:629:in `run_examples'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example_group.rb:595:in `run'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example_group.rb:596:in `block in run'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example_group.rb:596:in `map'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example_group.rb:596:in `run'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example_group.rb:596:in `block in run'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example_group.rb:596:in `map'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/example_group.rb:596:in `run'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/runner.rb:121:in `block (3 levels) in run_specs'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/runner.rb:121:in `map'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/runner.rb:121:in `block (2 levels) in run_specs'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/configuration.rb:2031:in `with_suite_hooks'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/runner.rb:116:in `block in run_specs'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/reporter.rb:74:in `report'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/runner.rb:115:in `run_specs'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/runner.rb:89:in `run'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/runner.rb:71:in `run'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/runner.rb:45:in `invoke'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/exe/rspec:4:in `<top (required)>'
# /Users/myuser/.rbenv/versions/2.7.0/bin/rspec:23:in `load'
# /Users/myuser/.rbenv/versions/2.7.0/bin/rspec:23:in `<top (required)>'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/2.7.0/bundler/cli/exec.rb:63:in `load'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/2.7.0/bundler/cli/exec.rb:63:in `kernel_load'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/2.7.0/bundler/cli/exec.rb:28:in `run'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/2.7.0/bundler/cli.rb:476:in `exec'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/2.7.0/bundler/cli.rb:30:in `dispatch'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/2.7.0/bundler/cli.rb:24:in `start'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bundler-2.1.2/libexec/bundle:46:in `block in <top (required)>'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/2.7.0/bundler/friendly_errors.rb:123:in `with_friendly_errors'
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bundler-2.1.2/libexec/bundle:34:in `<top (required)>'
# /Users/myuser/.rbenv/versions/2.7.0/bin/bundle:23:in `load'
# /Users/myuser/.rbenv/versions/2.7.0/bin/bundle:23:in `<main>'
#
# Showing full backtrace because every line was filtered out.
# See docs for RSpec::Configuration#backtrace_exclusion_patterns and
# RSpec::Configuration#backtrace_inclusion_patterns for more information.
# ------------------
# --- Caused by: ---
# Errno::EMFILE:
# Too many open files - socket(2) for "127.0.0.1" port 9518
# /Users/myuser/.rbenv/versions/2.7.0/lib/ruby/2.7.0/net/http.rb:960:in `initialize'
If you're using WebMock in your specs, then add the following to your rails_helper.rb:
WebMock.allow_net_connect!(net_http_connect_on_start: true)
or
WebMock.disable_net_connect!(net_http_connect_on_start: true)
source: https://github.com/bblimke/webmock/blob/master/README.md#connecting-on-nethttpstart
I have been getting the same error messages with Capybara feature specs since upgrading to ruby 2.7, and it has nothing to do with open files, per se. When Capybara misses a selector (in your case, probably find('.panel.#synopsis .btn', text: /new email/i)), it throws a socket(2) too many files error.
Edit: I had a Webmock call that seemed to be opening all the files (in other words: yeah, you get too many files open - socket(2) when something can’t be found ... but while Capybara was looking for the thing that couldn’t be found, Webmock was running amok).
Here’s the link: https://github.com/bblimke/webmock/blob/master/README.md#connecting-on-nethttpstart, which is a piggyback off of Pepa’s response below (it’s a reference inside the Capybara 'gotchas').
ulimit -Sn 10240 did the trick for me
-S Set a soft limit for the given resource.
-n The maximum number of open file descriptors.
You need to increase limit of file descriptors that are allowed to be open.
The simplest approach to do that is to add a line ulimit -n 65536 to your ~/.bash_profile or ~/.zshrc. That line will set ulimit to 65536 for new sessions.
an alternative solution would be cleaning tmp/cache
a computer restart may help as well
In my case, I was missing the id set in the HTML. Adding the id fixed it immediately.

I cannot access audited association on models after switching from SQLite3 to MySQL in Rails 4.2

I have been using the gem audited in my rails application. At first I was using a sqlite3 database but have recently switched over to MySQL. When I attempt to access my association that the gem provides (ex: myObject.audits) I get the following error.
`ArgumentError: undefined class/module ActiveRecord::ConnectionAdapters::SQLite3String
from /home/david/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych/class_loader.rb:53:in `path2class'
from /home/david/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych/class_loader.rb:53:in `resolve'
from /home/david/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych/class_loader.rb:45:in `find'
from /home/david/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych/class_loader.rb:27:in `load'
from /home/david/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych/visitors/to_ruby.rb:360:in `resolve_class'
from /home/david/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych/visitors/to_ruby.rb:203:in `visit_Psych_Nodes_Mapping'
from /home/david/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych/visitors/visitor.rb:15:in `visit'
from /home/david/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych/visitors/visitor.rb:5:in `accept'
from /home/david/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych/visitors/to_ruby.rb:31:in `accept'
from /home/david/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych/visitors/to_ruby.rb:302:in `block in revive_hash'
from /home/david/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych/visitors/to_ruby.rb:300:in `each'
from /home/david/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych/visitors/to_ruby.rb:300:in `each_slice'
from /home/david/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych/visitors/to_ruby.rb:300:in `revive_hash'
from /home/david/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych/visitors/to_ruby.rb:161:in `visit_Psych_Nodes_Mapping'
from /home/david/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych/visitors/visitor.rb:15:in `visit'
from /home/david/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych/visitors/visitor.rb:5:in `accept'
... 63 levels...
from /home/david/.rvm/gems/ruby-2.1.3/gems/activerecord-4.2.0/lib/active_record/attribute_set.rb:31:in `fetch_value'
from /home/david/.rvm/gems/ruby-2.1.3/gems/activerecord-4.2.0/lib/active_record/attribute_methods/read.rb:93:in `_read_attribute'
from /home/david/.rvm/gems/ruby-2.1.3/gems/activerecord-4.2.0/lib/active_record/attribute_methods/read.rb:87:in `read_attribute'
from /home/david/.rvm/gems/ruby-2.1.3/gems/activerecord-4.2.0/lib/active_record/attribute_methods.rb:305:in `attribute_for_inspect'
from /home/david/.rvm/gems/ruby-2.1.3/gems/activerecord-4.2.0/lib/active_record/core.rb:443:in `block in inspect'
from /home/david/.rvm/gems/ruby-2.1.3/gems/activerecord-4.2.0/lib/active_record/core.rb:441:in `collect'
from /home/david/.rvm/gems/ruby-2.1.3/gems/activerecord-4.2.0/lib/active_record/core.rb:441:in `inspect'
from /home/david/.rvm/gems/ruby-2.1.3/gems/activerecord-4.2.0/lib/active_record/relation.rb:629:in `map!'
from /home/david/.rvm/gems/ruby-2.1.3/gems/activerecord-4.2.0/lib/active_record/relation.rb:629:in `inspect'
from /home/david/.rvm/gems/ruby-2.1.3/gems/railties-4.2.0/lib/rails/commands/console.rb:110:in `start'
from /home/david/.rvm/gems/ruby-2.1.3/gems/railties-4.2.0/lib/rails/commands/console.rb:9:in `start'
from /home/david/.rvm/gems/ruby-2.1.3/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:68:in `console'
from /home/david/.rvm/gems/ruby-2.1.3/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/david/.rvm/gems/ruby-2.1.3/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'2.1.3 :004 >`
I'm not sure where to start debugging this error. Can anyone provide some direction? Thanks!

Error executing action `install` on resource 'package[mysql-devel]

I ran a recipe to install the mysql-client and mysql-server on my rhel6 linux box. The recipes used were downloaded from supermarket using knife tool.
i am following this tutorial step by step.
on executing this command:
chef-solo -c solo.rb -j web.json
====
I got the following error.
Recipe: mysql::client
* package[mysql] action install (up to date)
* package[mysql-devel] action install
================================================================================
**Error executing action `install` on resource 'package[mysql-devel]'**
================================================================================
Chef::Exceptions::Exec
----------------------
returned 1, expected 0
Resource Declaration:
---------------------
# In /home/subham/chef-repo/chef-repo/cookbooks/mysql/recipes/client.rb
47: package name
48: end
Compiled Resource:
------------------
# Declared in /home/subham/chef-repo/chef-repo/cookbooks/mysql/recipes/client.rb:47:in `block in from_file'
package("mysql-devel") do
action :install
retries 0
retry_delay 2
guard_interpreter :default
package_name "mysql-devel"
version "5.1.61-4.el6"
timeout 900
cookbook_name :mysql
recipe_name "client"
end
Running handlers:
[2014-11-26T06:22:23-05:00] ERROR: Running exception handlers
Running handlers complete
[2014-11-26T06:22:23-05:00] ERROR: Exception handlers complete
[2014-11-26T06:22:23-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 1 resources updated in 29.10138575 seconds
[2014-11-26T06:22:24-05:00] ERROR: package[mysql-devel] (mysql::client line 47) had an error: Chef::Exceptions::Exec: returned 1, expected 0
[2014-11-26T06:22:24-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Stacktrace at /var/chef/cache/chef-stacktrace.out
Generated at 2014-11-26 06:22:23 -0500
Chef::Exceptions::Exec: package[mysql-devel] (mysql::client line 47) had an error: Chef::Exceptions::Exec: returned 1, expected 0
/opt/chefdk/embedded/apps/chef/lib/chef/mixin/command.rb:158:in `handle_command_failures'
/opt/chefdk/embedded/apps/chef/lib/chef/provider/package/yum.rb:1021:in `yum_command'
/opt/chefdk/embedded/apps/chef/lib/chef/provider/package/yum.rb:1136:in `install_package'
/opt/chefdk/embedded/apps/chef/lib/chef/provider/package.rb:82:in `block in action_install'
/opt/chefdk/embedded/apps/chef/lib/chef/mixin/why_run.rb:52:in `call'
/opt/chefdk/embedded/apps/chef/lib/chef/mixin/why_run.rb:52:in `add_action'
/opt/chefdk/embedded/apps/chef/lib/chef/provider.rb:156:in `converge_by'
/opt/chefdk/embedded/apps/chef/lib/chef/provider/package.rb:80:in `action_install'
/opt/chefdk/embedded/apps/chef/lib/chef/provider.rb:121:in `run_action'
/opt/chefdk/embedded/apps/chef/lib/chef/resource.rb:648:in `run_action'
/opt/chefdk/embedded/apps/chef/lib/chef/runner.rb:49:in `run_action'
/opt/chefdk/embedded/apps/chef/lib/chef/runner.rb:81:in `block (2 levels) in converge'
/opt/chefdk/embedded/apps/chef/lib/chef/runner.rb:81:in `each'
/opt/chefdk/embedded/apps/chef/lib/chef/runner.rb:81:in `block in converge'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection.rb:98:in `block in execute_each_resource'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection.rb:96:in `execute_each_resource'
/opt/chefdk/embedded/apps/chef/lib/chef/runner.rb:80:in `converge'
/opt/chefdk/embedded/apps/chef/lib/chef/client.rb:345:in `converge'
/opt/chefdk/embedded/apps/chef/lib/chef/client.rb:431:in `do_run'
/opt/chefdk/embedded/apps/chef/lib/chef/client.rb:213:in `block in run'
/opt/chefdk/embedded/apps/chef/lib/chef/client.rb:207:in `fork'
/opt/chefdk/embedded/apps/chef/lib/chef/client.rb:207:in `run'
/opt/chefdk/embedded/apps/chef/lib/chef/application.rb:236:in `run_chef_client'
/opt/chefdk/embedded/apps/chef/lib/chef/application/solo.rb:226:in `block in run_application'
/opt/chefdk/embedded/apps/chef/lib/chef/application/solo.rb:218:in `loop'
/opt/chefdk/embedded/apps/chef/lib/chef/application/solo.rb:218:in `run_application'
/opt/chefdk/embedded/apps/chef/lib/chef/application.rb:55:in `run'
/opt/chefdk/embedded/apps/chef/bin/chef-solo:25:in `<top (required)>'
/usr/bin/chef-solo:33:in `load'
/usr/bin/chef-solo:33:in `<main>'
File at /home/subham/chef-repo/chef-repo/cookbooks/mysql/recipes/client.rb
line 46 : node['mysql']['client']['packages'].each do |name|
line 47 : package name
line 48 : end
In the header comment section of the same file
# Include Opscode helper in Recipe class to get access
# to debian_before_squeeze? and ubuntu_before_lucid?
Does it mean that this recipe will only work in debian family based systems like ubuntu and not in RHEL or fedora/Cent OS ?
If yes then what changes i need to perform ?

Rails 3.2 activerecord-jdbc-adapter error

I have just updated to rails 3.2 running on JRuby-1.6.5 and when I run rake db:migrate, I get the following error:
undefined method `accept' for nil:NilClass
Here is the trace:
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in
to_sql'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:36:in
select_values'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/activerecord-3.2.1/lib/active_record/migration.rb:571:in
get_all_versions'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/activerecord-3.2.1/lib/active_record/migration.rb:729:in
migrated'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/activerecord-3.2.1/lib/active_record/migration.rb:652:in
current_version'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/activerecord-3.2.1/lib/active_record/migration.rb:669:in
migrate' org/jruby/RubyEnumerable.java:552:in detect'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/activerecord-3.2.1/lib/active_record/migration.rb:669:in
migrate'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/activerecord-3.2.1/lib/active_record/migration.rb:554:in
up'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/activerecord-3.2.1/lib/active_record/migration.rb:535:in
migrate'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/activerecord-3.2.1/lib/active_record/railties/databases.rake:153:in
(root)' org/jruby/RubyProc.java:258:incall'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/rake-0.9.2.2/lib/rake/task.rb:205:in
execute' org/jruby/RubyArray.java:1612:ineach'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/rake-0.9.2.2/lib/rake/task.rb:200:in
execute'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/rake-0.9.2.2/lib/rake/task.rb:158:in
invoke_with_call_chain'
/Users/paulcowan/.rvm/rubies/jruby-1.6.5/lib/ruby/1.9/monitor.rb:201:in
mon_synchronize'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/rake-0.9.2.2/lib/rake/task.rb:151:in
invoke_with_call_chain'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/rake-0.9.2.2/lib/rake/task.rb:144:in
invoke'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/rake-0.9.2.2/lib/rake/application.rb:116:in
invoke_task'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/rake-0.9.2.2/lib/rake/application.rb:94:in
top_level' org/jruby/RubyArray.java:1612:ineach'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/rake-0.9.2.2/lib/rake/application.rb:94:in
top_level'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/rake-0.9.2.2/lib/rake/application.rb:133:in
standard_exception_handling'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/rake-0.9.2.2/lib/rake/application.rb:88:in
top_level'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/rake-0.9.2.2/lib/rake/application.rb:66:in
run'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/rake-0.9.2.2/lib/rake/application.rb:133:in
standard_exception_handling'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/rake-0.9.2.2/lib/rake/application.rb:63:in
run'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/gems/rake-0.9.2.2/bin/rake:33:in
(root)' org/jruby/RubyKernel.java:1073:inload'
/Users/paulcowan/.rvm/gems/jruby-1.6.5/bin/rake:19:in `(root)' Tasks:
TOP => db:migrate
The error appears to be coming from activerecord-jdbc-adapter.
I am referencing the master in my gem file:
gem 'activerecord-jdbc-adapter', :git => "https://github.com/nicksieger/activerecord-jdbc-adapter.git", :branch => 'master'
Has anybody else had this error or it there a resolution.

Ruby on Rails Import CSV into MySQL

Newbie question....
Trying to start a project in rails. I have different spreadsheets in csv format I'd like to import into the MySQL database to be able to manipulate the data.
After looking around on stackoverflow, Google, etc. I wrote a rake task requiring fastercsv to do the job. I keep getting errors so hopefully you can help.
...
Ok so I changed the code to use 'csv' vs 'fastercsv'...still getting errors. See below
New Code for Rake File (take 3):
require 'csv'
desc "Import gac from csv file"
task :import => [:environment] do
file = "gac.csv"
CSV.foreach(file, :headers => true) do |row|
Institution.create({
:institution_name => row[0],
:website => row[1],
:email => row[2],
:category_1 => row[3],
:category_2 => row[4],
:category_3 => row[5],
:category_4 => row[6],
:category_5 => row[7],
:category_6 => row[8],
:category_7 => row[9],
:category_8 => row[10],
:category_9 => row[11],
:category_10 => row[12],
:category_11 => row[13],
:institution_description => row[14]
})
end
end
Error Codes:
Daves-MacBook-Pro:vendor dave$ rake import --trace
** Invoke import (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute import
rake aborted!
invalid byte sequence in UTF-8
/Users/dave/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/csv.rb:1855:in `sub!'
/Users/dave/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/csv.rb:1855:in `block in shift'
/Users/dave/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/csv.rb:1849:in `loop'
/Users/dave/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/csv.rb:1849:in `shift'
/Users/dave/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/csv.rb:1791:in `each'
/Users/dave/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/csv.rb:1208:in `block in foreach'
/Users/dave/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/csv.rb:1354:in `open'
/Users/dave/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/csv.rb:1207:in `foreach'
/Users/dave/rails_projects/vendor/lib/tasks/import.rake:8:in `block in <top (required)>'
/Users/dave/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/dave/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/dave/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/dave/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/dave/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/dave/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/dave/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/dave/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/dave/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/dave/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/dave/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/dave/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/dave/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/dave/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/dave/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/dave/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/dave/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/dave/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/dave/.rvm/gems/ruby-1.9.3-p0/bin/rake:19:in `load'
/Users/dave/.rvm/gems/ruby-1.9.3-p0/bin/rake:19:in `<main>'
Tasks: TOP => import
lib/tasks/import.rake
require 'csv'
desc "Import gac from csv file"
task :import => [:environment] do
file = "vender/gac.csv"
CSV.foreach(file, :headers => true) do |row|
Putthemodelnamehere.create ({
:columnnamewhatever => row[1],
:columnname => row[2],
:columnname => row[4]
})
end
end
Then just run rake import or bundle exec rake import. Hope this helps (this isn't using fastercsv but this is the solution I'd recommend.)
Make sure that you have the Institution model class defined in app/models and/or make sure that you have run the db migration(s) (rake db:migrate) to create the institutions table - assuming you used a generator (or scaffold) to create the model.
The errors you are getting are probably because there is something in your csv that is not properly encoded for UTF-8.
One way of dealing with that would be to force the encoding. You could do the following:
For each association you have above, do this instead:
:category_1 => row[3].encode("UTF-8", replace: ' '),
Hopefully that will work for you.