UNDEFINED METHOD `ACCEPT’ FOR NIL:NILCLASS Ruby on Rails

Pues bueno hoy comparto con ustedes un error que me quito algunas horas en resolverlo, aquí esta la solución.
Este es el error que muestra ruby on rails al momento de acceder a la aplicación.

NoMethodError

undefined method `accept’ for nil:NilClass

Rails.root: /home/rails

Application Trace | Framework Trace | Full Trace

<code>activerecord (4.0.2) lib/active_record/connection_adapters/abstract/database_statements.rb:13:in `to_sql'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/database_statements.rb:24:in `select_all'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all'
activerecord (4.0.2) lib/active_record/querying.rb:36:in `find_by_sql'
activerecord (4.0.2) lib/active_record/relation.rb:585:in `exec_queries'</code>

No tenia ni idea de donde problenia este error, lo unico de lo que estaba seguro fue que se origino después de ejecutar el bundle update y bundle install ya que tenia un error de incompatibilidad con la gema de mysql.

ruby on rails

pero a pesar que se descargo la ultima versión y que era la compatible el error me seguía apareciendo. busque ayuda pero nada, lo raro era el warnin que me aparecia al momento de ejecutar el comanro rake routes el cual era el siguiente:

============= WARNING FROM mysql2 =============
This version of mysql2 (0.2.23) isn’t compatible with Rails 3.1 as the ActiveRecord adapter was pulled into Rails itself.
Please use the 0.3.x (or greater) releases if you plan on using it in Rails >= 3.1.x
============= END WARNING FROM mysql2 =============

Este mismo error era el mismo que me aparecia en el log de errores, continuación muestro parte del log (Final del post).

De algo si estaba seguro y era de que por alguna razon ruby on rails seguia tomando la gema 2.1.3 que oviamente no era compatible con Rails 3.1, pero como era esto posible si en el archivo gemfile especifique:

gem ‘mysql2’, ‘~> 0.3.16’  y también intente sin indicar la versión (por lo cual debería tomar la ultima versión),

por lo que decidí eliminar todas las gemas de mysql2 y dejar unidamente, pero apesar de que la gema 0.2.23 ya no estaba, me el error continuaba 🙁

Después de unas horas comprobé una nueva teoría, y era de que el archivo Gemfile.lock(archivo o actualiza que se crea apartir de gemfile y bundle update) no se estaba actualizando.

Solución

Elimine el archivo, por lo cual force a que se volviera a crear y esta vez actualizado, con el gemfile, y todo volvió a funcionar como antes.

 

Parte de mi log

/usr/local/rvm/gems/ruby-2.1.3/gems/bundler-1.7.3/lib/bundler/runtime.rb:222: warning: Insecure world writable dir /home/rails in PATH, mode 046777
/usr/local/rvm/gems/ruby-2.1.3/gems/bundler-1.7.3/lib/bundler/runtime.rb:222: warning: Insecure world writable dir /home/rails in PATH, mode 046777
/usr/local/rvm/gems/ruby-2.1.3/gems/bundler-1.7.3/lib/bundler/runtime.rb:222: warning: Insecure world writable dir /home/rails in PATH, mode 046777
/usr/local/rvm/gems/ruby-2.1.3/gems/bundler-1.7.3/lib/bundler/runtime.rb:222: warning: Insecure world writable dir /home/rails in PATH, mode 046777
============= WARNING FROM mysql2 =============
This version of mysql2 (0.2.23) isn’t compatible with Rails 3.1 as the ActiveRecord adapter was pulled into Rails itself.
Please use the 0.3.x (or greater) releases if you plan on using it in Rails >= 3.1.x
============= END WARNING FROM mysql2 =============
============= WARNING FROM mysql2 =============
This version of mysql2 (0.2.23) isn’t compatible with Rails 3.1 as the ActiveRecord adapter was pulled into Rails itself.
Please use the 0.3.x (or greater) releases if you plan on using it in Rails >= 3.1.x
============= END WARNING FROM mysql2 =============
============= WARNING FROM mysql2 =============
This version of mysql2 (0.2.23) isn’t compatible with Rails 3.1 as the ActiveRecord adapter was pulled into Rails itself.
Please use the 0.3.x (or greater) releases if you plan on using it in Rails >= 3.1.x
============= END WARNING FROM mysql2 =============
============= WARNING FROM mysql2 =============
This version of mysql2 (0.2.23) isn’t compatible with Rails 3.1 as the ActiveRecord adapter was pulled into Rails itself.
Please use the 0.3.x (or greater) releases if you plan on using it in Rails >= 3.1.x
============= END WARNING FROM mysql2 =============
/usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require’: Could not load ‘active_record/connection_adapters/jdbcmysql_adapter’. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than ‘mysql’, ‘mysql2’, ‘postgresql’ or ‘sqlite3′ add the necessary adapter gem to the Gemfile. (LoadError)
from /usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require’
from /usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency’
from /usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require’

Leave a Reply

Your email address will not be published. Required fields are marked *