Simple Rails App: Error Cannot visit Integer
The version of Ruby you're using (2.4.1) is not compatible with the version of Rails you're using (3.2.22.5). That version of Ruby requires at least Rails 5. Try downgrading to Ruby 2.3 or lower. You can use a Ruby version manager (i.e. rvm
, rbenv
or chruby
) to control which Ruby is used when launching your application.
Edit
Just noticed you're already using rbenv
from your stack trace. Add a .ruby-version
file to your application's directory containing the following line:
2.3.4
Once you re-enter that directory, confirm the version via:
$> ruby -v
ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-darwin16]
(or similar version) before launching rails.
I got this error yesterday and created a workaround which should make it work with ruby 2.4 and rails 3.2.
The commit that I got the idea from is at: https://github.com/rails/arel/commit/dc85a6e9c74942945ad696f5da4d82490a85b865
Just include the following in your rails initializers.
module Arel
module Visitors
class DepthFirst < Arel::Visitors::Visitor
alias :visit_Integer :terminal
end
class Dot < Arel::Visitors::Visitor
alias :visit_Integer :visit_String
end
class ToSql < Arel::Visitors::Visitor
alias :visit_Integer :literal
end
end
end
For future Googlers. I had the same problem but I needed to apply a variant of Thomas Dziedzic solution.
I have ruby 2.5.1
and rails 4.2.10
running in my system.
As shown in this commit ToSql was changed from Arel::Visitors::Visitor
to Arel::Visitors::Reduce
So this is my updated solution. In a rails initializer put this:
module Arel
module Visitors
class DepthFirst < Arel::Visitors::Visitor
alias :visit_Integer :terminal
end
class Dot < Arel::Visitors::Visitor
alias :visit_Integer :visit_String
end
class ToSql < Arel::Visitors::Reduce
alias :visit_Integer :literal
end
end
end