0

I'm trying to make it so if a user has accepted an invite, they have the option of clicking the not_attending div to cancel the invite.

However, I'd like the not_attending div to remain present even if a user hasn't accepted an invite, just without a link.

Someone in another thread kindly pointed me toward the link_to_if method, which takes arguments in the form:

link_to_if(condition, name, options = {}, html_options = {}, &block)

Here is the code I'm working with:

<%= link_to_if(invite.accepted, "Name I Don't Want", not_attending_path) %>                             
    <div class="not_attending_div">
         not attending
    </div>

So, is there a way to use the not_attending div as the name parameter, similiar to how you can augment link_to in the following fashion:

<%= link_to(users_path) do %>
  <div id="fancydiv">This div is more than just text</div>
<% end %>
Adam Templeton
  • 4,467
  • 7
  • 27
  • 39

1 Answers1

1

You could do this two ways off the top of my head:

<%= link_to(users_path) do %>
  <div id="fancydiv">This div is more than just text</div>
<% end if invite.accepted %>

or

<%= link_to_if(invite.accepted, content_tag(:div, "Some div text", :id => "fancydiv"), not_attending_path) %>  
Kyle d'Oliveira
  • 6,382
  • 1
  • 27
  • 33