我有以下的標記部分插入文本的link_to Rails中
%span.tag-label
= link_to "#{tag}" , :controller => "searches", :action => "search_tags", :search_type => search_type,
:tag_type => tag_type, :tag =>"#{tag}"
和我通過標記部分爲集合:
= render "shared/tag_item", :collection => @listing.keyword_list, :as => :tag,
:search_type => "Listing", :tag_type => nil
出於某種原因,我得到這個錯誤:
wrong number of arguments (0 for 1)
在我的部分。
如果我只是把純文本放在link_to "text"
和tag =>"text"
那麼它就可以工作。 爲什麼我的嵌入文本"#{tag}"
在這種情況下不起作用?
謝謝。 更新顯示錯誤跟蹤: `endered列表/佈局內show.html.haml /應用(148.4ms) 完成500內部服務器錯誤在232ms
ActionView::Template::Error (wrong number of arguments (0 for 1)):
1: %span.tag-label
2: = link_to "#{tag.to_s}" , :controller => "searches", :action => "search_tags", :search_type => search_type,
3: :tag_type => tag_type, :tag =>"#{tag.to_s}"
<a href="txmt://open?url=file:///Users/app/views/shared/_tag_item.html.haml&line=2&column=1">app/views/shared/_tag_item.html.haml
顯示錯誤發生位置的錯誤跟蹤。 – Zabba 2012-04-08 02:28:33
確保'link_to「#{tag}」,''實際上'link_to「#{tag}」,' – 2012-04-08 02:47:46
如果您只輸出'url_for(:controller =>「searching」,:action =>「search_tags」,: search_type => search_type, :tag_type => tag_type,:tag =>「#{tag}」)'而不是'link_to..'按預期輸出嗎? – 2012-04-08 03:38:11