我期待創建一個字符串命名的路由和傳遞一個對象到它命名路由與對象
我渲染的部分與當地的「資源」
即。 render :partial => "listing", :locals => {:resource => @resource}
內_listing.html.haml我使用self.send方法
self.send("#{resource.class.to_s.downcase}_path()")
這工作得很好,並創建一個名爲路線 即資源。 article_path()
但是這條路線需要一個在路線 即傳遞的對象。 article_path(文章)
我試圖此
self.send("#{resource.class.to_s.downcase}_path("+resource+")")
並且得到錯誤 不能轉換成條串
有什麼建議?
後的修修補補很多,我發現答案很簡單。 修復是使它逗號分隔 _listing.html.haml - resource_path = 「#{} resource.class.to_s.downcase _path」 =的link_to resource.title,送(resource_path,資源) 希望這可以幫助任何與我一樣掙扎的人 – 2012-01-27 12:40:44