LINK_TO从类中删除按钮:不能转换成字符串哈希
问题描述:
我有这个简单的Ruby类(我用它从一个控制器内创建产品的集合):LINK_TO从类中删除按钮:不能转换成字符串哈希
class ProductDashboardDecorator
include ApplicationHelper
include ActionView::Helpers::NumberHelper
include ActionView::Helpers::TagHelper
include ActionView::Helpers::AssetTagHelper
include ActionView::Helpers::UrlHelper
include ActionController::UrlWriter
def initialize(p)
@product = p
end
def special_links
ret = ''
# this works!
ret << content_tag(:a, 'X', :href => removee_product_path(@product), :title => 'rimuovi', :class => 'remove_link', :method => :delete)
# this don't!
ret << link_to('X', removee_product_path(@product), :title => 'rimuovi', :class => 'remove_link', :method => :delete)
return ret.html_safe
end
end
我想用link_to创建一个“删除”按钮。但是,当我这样做,我得到这个错误:
can't convert String into Hash
这些路线:
map.resources :products, :member => { :removee => :delete }, :as => 'prodotti' do |product|
product.resources :watchers, :collection => { :add => :get }
end
任何帮助吗?
答
尝试该语法中,未测试
content_tag(:span, link_to('X', removee_product_path(@product), :title => 'rimuovi', :class => 'remove_link', :method => :delete))
此总是产生的问题:的link_to( 'X',removee_product_path(@product))。相同的错误 – 2014-09-25 13:27:14
@MichDart语法看起来不错 – Nithin 2014-09-25 13:32:04