Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 为什么给我这个错误;can';t将字符串转换为哈希值“;使用RoR ActionView::Helpers::UrlHelper和ActionController::UrlWriter?_Ruby On Rails_Ruby_Hyperlink_Helper - Fatal编程技术网

Ruby on rails 为什么给我这个错误;can';t将字符串转换为哈希值“;使用RoR ActionView::Helpers::UrlHelper和ActionController::UrlWriter?

Ruby on rails 为什么给我这个错误;can';t将字符串转换为哈希值“;使用RoR ActionView::Helpers::UrlHelper和ActionController::UrlWriter?,ruby-on-rails,ruby,hyperlink,helper,Ruby On Rails,Ruby,Hyperlink,Helper,我的控制器里有这个 include ActionView::Helpers::UrlHelper include ActionController::UrlWriter include ApplicationHelper::TextHelper TextHelper有类似的功能 var = { "name1"=>link_to('string1', home_page_path), "name2"=>link_to('string2',

我的控制器里有这个

     include ActionView::Helpers::UrlHelper
     include ActionController::UrlWriter
     include ApplicationHelper::TextHelper
TextHelper有类似的功能

var = {
    "name1"=>link_to('string1', home_page_path),
    "name2"=>link_to('string2', :controller=>'xxxxx/xxxx', :action=>'info_xxx', :return_to=>'/xxxxxxxx'),
    "name3"=>link_to('string3', 'http://www.url.com', :target=>'_blank'),
    "name4"=>link_to('string4', :controller => 'xxxxxx/xxxxx')
  }
name2
name4
给我一个错误“无法将字符串转换为哈希”,这是因为
ActionView::Helpers::UrlHelper
ActionController::UrlWriter
url\u的实现不同,其中一个没有管理
Hash

如果我删除
ActionController::UrlWriter
我会得到错误

undefined method `url_for' for nil:NilClass
如果我删除
ActionView::Helpers::UrlHelper
给我

undefined method `link_to' for #<xxxxxx::xxxxx::xxxxxxController:0xc3d276c>
未定义的方法“链接到”#
我使用的是ruby 1.9.3和Rails 2.3.8,我不能在
TextHelper
中更改var中的任何内容,也不能在
ActionView::Helpers::UrlHelper
ActionController::UrlWriter
中更改任何实现

有什么解决办法吗