我已经在这个库中看到这个代码:的link_to与Rails的块
<%= link_to(:controller => 'account', :action => 'select', :account_id => account.customer_id) { account.customer_id.to_s } %>
(<%= account.login %>/<%= account.company_name %>)
这实际上转换为下面的HTML:
<a account_id="8282277272" action="select" controller="account">8282277272</a>
(loginname/companyname)
我想知道你将如何传递到的link_to块为了使这项工作?
我不关注。为什么会需要一个块。您发布的代码不使用或不需要块。 – cpjolicoeur
您可以看到{account.customer_id.to_s}被传递给link_to。我不确定为什么开发者会这样做,但我知道一个块可以通过。 –
尝试使用url_for:link_to(url_for(:controller =>'account',:action =>'select',:account_id => account.customer_id)){account.customer_id.to_s}' – MrYoshiji