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

  • SEARCH
  • Home
  • 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 8335253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:37:11+00:00 2026-06-09T03:37:11+00:00

In my view, I am testing to see if certain records exist. If they

  • 0

In my view, I am testing to see if certain records exist. If they do, I iterate over them and display each one. If these records do not exist, however, I want a message to be displayed. Here is the code from my view:

      <% if current_user.lineups %>
        <% for lineup in current_user.lineups do %>
          <li><%= link_to "#{lineup.course.cl} #{lineup.course.cn}", index_path %></li>
        <% end %>
      <% else %>
        <li><%= link_to "You have no courses", index_path %></li>
      <% end %>

Now, the iteration works just fine when the records exist. Whenever I create the proper records, this code works marvelously and creates a link for each record that is iterated over. However, If no records exists, nothing is displayed. The ‘else’ statement is completely ignored. I tried amending the ‘if’ stament but to no avail. I tried:

<% unless current_user.lineups.nil? %>

As well as:

<% if !( current_user.lineups.nil? ) %>

I am at my wits end here. Any and all input would be appreciated.

  • 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-09T03:37:13+00:00Added an answer on June 9, 2026 at 3:37 am

    try this in your if statement

    <% if current_user.lineups.blank? %>
       <li><%= link_to "You have no courses", index_path %></li>
    <% else %>
       <% for lineup in current_user.lineups do %>
          <li><%= link_to "#{lineup.course.cl} #{lineup.course.cn}", index_path %></li>
       <% end %> 
    <% end %>
    

    it will check lineups array is empty or nil both the cases.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

By 'view' here I mean different combinations of properties of the model, not the
I'm testing out CouchDB to see how it could handle logging some search results.
Dreadful title right? Thought I'd see if Stack overflow is quicker than me testing
I'm doing some testing of QT Quick to see if i can use it
I was testing a model repository to see if it calls the message bus.
I see how Xcode 4 splits the info on your targets nicely in one
I have a simple Rails 3 app: no models, one view and one controller
I currently sending ipa to friends for testing. Funny thing is, one of my
I see the benefit of passing dependencies between view controllers (injecting) as opposed to
I am testing my controller but requests are coming via ajax. I do not

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.