Ruby on Rails:没有将Array转换成String(DEVISE) [英] Ruby on Rails: no implicit conversion of Array into String (DEVISE)

查看:818
本文介绍了Ruby on Rails:没有将Array转换成String(DEVISE)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近从10.7升级到OSX小牛10.9,从那以后,一直造成很多麻烦。我升级了Xcode,命令行工具,重新安装了homebrew和rvm,最后得到了rails的工作(我花了5个小时让rmagick再次工作)。



但是,现在当我尝试从本地主机访问我的应用程序时,我收到这个错误

 没有将数组转换成字符串

这是rails日志: / p>

 在2014-05-05 02:20:00 -0700 
开始获取/为127.0.0.1由AccountController#dashboard作为HTML
在0.3ms内完成500内部服务器错误

TypeError(没有将数组转换成字符串):
app / controllers / application_controller.rb:26 :在`check_correct_subdomain'


渲染/Users/kibaek/.rvm/gems/ruby-2.1.0@onvard/gems/actionpack-3.2.16/lib/action_dispatch/middleware/模板/救援/ _trace.erb(1.0ms)
渲染/Users/kibaek/.rvm/gems/ruby-2.1.0@onvard/gems/actionpack-3.2.16/lib/action_dispatch/middleware/templates/拯救/ _request_and_response.erb(0.8ms)
呈现/Users/kibaek/.rvm/gems/ruby-2.1.0@onvard/gems/actionpack-3.2.16/lib/action_dispatch/middle在拯救/布局(7.1ms)中的商品/模板/拯救/诊断.erb

这是application_controller。 rb其中错误被调用:

  def check_correct_subdomain 
如果current_user
redirect_to root_url(subdomain:current_user .account.domain)if request.subdomain!= current_user.account.domain
end
end

这是我的版本:

  Kibaeks-MacBook-Pro:onvard_saas kibaek $ ruby​​ -v 
ruby 2.1.0p0(2013-12-25修订版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版本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/]




  • 我们在轨道3.2.16和ruby 2.1.0之前,我的小牛升级。我刚刚重新安装了homebrew,rvm和rails / ruby​​到同一个版本。



我把它推到了分段服务器,我的其他开发人员说,它在他的机器上在本地工作,所以我认为它可能是我在升级到小牛的过程中做的,或者在尝试修复imagemagick / rmagick错误时复制+粘贴一堆东西。



*我可以访问我的其他rails项目,只是得到这个没有隐含的转换错误在这个特定的应用程序突然间。



有什么特别的原因,我会在本地机器上得到这个错误,当其他开发人员没有得到它? (我认为这是我的本地设置导致问题,而不是代码)






编辑:原来成为会议的设计问题。我能够通过 Devise从1.1.5升级到1.4.5导致错误的参数数量错误

解决方案

p>谢谢你们的答案!所以似乎这是导致错误的会话的一个问题..



我能够通过以下从1.1.5升级到1.4。 5导致错误参数数量错误



我运行 rake tmp:clear 并更改了在session_store.rb文件中的关键。



哇我花了14个小时试图解决这个问题,事实证明有一个这么简单的解决方案。

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..

这篇关于Ruby on Rails:没有将Array转换成String(DEVISE)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆