Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8147629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:24:44+00:00 2026-06-06T14:24:44+00:00

In the code below, I’m trying to make it so that, if a user

  • 0

In the code below, I’m trying to make it so that, if a user has accepted an invite, they’ll be able to click on the “not attending” div to decline the invite.

That bit of logic works fine, but I’m trying to get it so the “not attending” div shows up regardless of whether the user has accepted the invite.

Right now, the div only appears if the user has accepted the invite.

Is there a way to make the link_to statement conditional, but preserve the div regardless? (That is, make it so the div is always present, but is only a link if the user’s accepted the invite?)

<% if invite.accepted %>
    <%= link_to(:controller => "invites", :action => "not_attending") do %>                             
        <div class="not_attending_div">
             not attending
        </div>
    <% end %>
<% end %>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:24:46+00:00Added an answer on June 6, 2026 at 2:24 pm
    <%= link_to_if invite.accepted ... %>
    

    http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to_if

    Edit:

    link_to_if uses link_to_unless which uses link_to ‘s code, it should work the same with the same options

      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
    

    Example

    <%=
       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
    %>
    

    check it here http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to_unless

    Edit:

    Does this achieve what you need. Sorry, for not reading the question better.

    <div class="not_attending_div">
       <%= link_to_if invite.accepted, "not attending", (:controller => "invites", :action => "not_attending") %>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code below disables a textarea when trhe user has added the maximum rows
The code below removes www., etc. from the beginning of websites that are entered
The code below allows the user to enter in a phrase in plain English,
Code below defines a ChargeCustomer class that contains an array of type customers. I
Code below is pseudo code. Imagine a class Fruit which has a factory method
(Code below has been updated and worked properly) There is dynamic OrderBy sample from
The code below is for saving friends list from facebook. Profile[] f=user.getFriends(); for(int i=0;i<f.length;i++){
My code below kinda works, it creates the User object and saves but it
Code below contains a JS function that receives as parameter String €€ (Euro sign).
Code below. The outcome of this is that each document ends up with the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.