<%= link_to_if invite.accepted ... %>
http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to_if
编辑:
link_to_if
uses link_to_unless
which useslink_to
的代码,它应该与相同的选项工作相同
def link_to_unless(condition, name, options = {}, html_options = {}, &block)
if condition
if block_given?
block.arity <= 1 ? capture(name, &block) : capture(name, options, html_options, &block)
else
name
end
else
link_to(name, options, html_options)
end
end
例子
<%=
link_to_if(@current_user.nil?, "Login", { :controller => "sessions", :action => "new" }) do
link_to(@current_user.login, { :controller => "accounts", :action => "show", :id => @current_user })
end
%>
在这里查看http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to_unless
编辑:
这是否达到了你所需要的。对不起,没有更好地阅读这个问题。
<div class="not_attending_div">
<%= link_to_if invite.accepted, "not attending", (:controller => "invites", :action => "not_attending") %>
</div>