1
我有這個簡單的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
任何幫助嗎?
此總是產生的問題:的link_to( 'X',removee_product_path(@product))。相同的錯誤 – 2014-09-25 13:27:14
@MichDart語法看起來不錯 – Nithin 2014-09-25 13:32:04