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
中更改任何实现
有什么解决办法吗