Mike Ray
Mike Ray

Reputation: 91

syntax error, unexpected keyword_else, expecting keyword_end '; else ^

Job#new

<ul>
<% if current_user.jobs.any? %>
<% current_user.jobs.each do |job| %>
<li> Job ID: <%= job.id %> Recipient: <%= job.recipient %> </li>
<% else %>
<%= "You have no jobs" %>
<% end %>
<% end %>

Not sure what I'm missing here.

Upvotes: 1

Views: 4275

Answers (1)

gFontaniva
gFontaniva

Reputation: 903

Try it:

<ul>
<% if current_user.jobs.any? %>
  <% current_user.jobs.each do |job| %>
    <li> Job ID: <%= job.id %> Recipient: <%= job.recipient %> </li>
  <% end %>
<% else %>
  <%= "You have no jobs" %>
<% end %>

You are opening an each and forget close else before

Upvotes: 5

Related Questions