I recently upgraded to OSX Mavericks 10.9 from 10.7, and since then it has been causing me lots of troubles. I upgraded Xcode, Command line tools, reinstalled homebrew and rvm, and finally got rails s to work (I spent a good 5 hours getting rmagick to work again).
However, now when I try to access my app from my localhost, I get this error
no implicit conversion of Array into String
Here is the rails log:
Started GET "/" for 127.0.0.1 at 2014-05-05 02:20:00 -0700
Processing by AccountsController#dashboard as HTML
Completed 500 Internal Server Error in 0.3ms
TypeError (no implicit conversion of Array into String):
app/controllers/application_controller.rb:26:in `check_correct_subdomain'
Rendered /Users/kibaek/.rvm/gems/ruby-2.1.0@onvard/gems/actionpack-3.2.16/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.0ms)
Rendered /Users/kibaek/.rvm/gems/ruby-2.1.0@onvard/gems/actionpack-3.2.16/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.8ms)
Rendered /Users/kibaek/.rvm/gems/ruby-2.1.0@onvard/gems/actionpack-3.2.16/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (7.1ms)
This is application_controller.rb where the error is getting called:
def check_correct_subdomain
if current_user
redirect_to root_url(subdomain: current_user.account.domain) if request.subdomain != current_user.account.domain
end
end
Here are my versions:
Kibaeks-MacBook-Pro:onvard_saas kibaek$ ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin12.0]
Kibaeks-MacBook-Pro:onvard_saas kibaek$ rails -v
Rails 3.2.16
Kibaeks-MacBook-Pro:onvard_saas kibaek$ bundle -v
Bundler version 1.5.1
Kibaeks-MacBook-Pro:onvard_saas kibaek$ rvm -v
rvm 1.25.25 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
- We were on rails 3.2.16 and ruby 2.1.0 prior to my mavericks upgrade as well. i just reinstalled homebrew, rvm and rails/ruby to the same version.
I pushed this to the staging server, and my other developer says it is working locally on his machine, so I think it may have been something I did in the process of upgrading to Mavericks or copy+pasting a bunch of stuff while trying to fix the imagemagick/rmagick error..
*I'm able to access my other rails projects, just get this no implicit conversion error on this particular app all of a sudden.
Is there any particular reason that I would be getting this error on my local machine, when the other developers don't get it? (I'm thinking it's my local settings that are causing the issue, not the code)
Edit: This turned out to be a devise issue with sessions. I was able to solve it through Devise upgrade from 1.1.5 to 1.4.5 causes Wrong Number of Arguments error
Thank you guys for the answers! So it seems like it was a problem with the sessions that was causing the error..
I was able to solve this by following Devise upgrade from 1.1.5 to 1.4.5 causes Wrong Number of Arguments error
I ran rake tmp:clear
and changed the name of the key in the session_store.rb file.
Wow I spent 14 hours trying to solve this issue and it turns out there was such an easy solution..
It appears that both of the following in your code are evaluating arrays:
if current_user
if affiliate
Calling if on an array will give you this error.
I am unsure why you would have current_user as an array unless you are setting it somewhere else in your code, check anywhere you have current_user =
For affiliate, find_by_token is returning an array, perhaps try one of the following:
if affiliate.present?
if !affiliate.nil?
来源:https://stackoverflow.com/questions/23469084/ruby-on-rails-no-implicit-conversion-of-array-into-string-devise