Hi
I ahve a code like
<%@attachment=ServiceDeskActivityAttachment.find_by_service_desk_activity_id(@sd_activities[loop_index].id)
%>
<% if !@attachment.blank? %>
<%= puts 'is empty'%>
<td class="searchResultLineItem1">No attachment</td>
<% end %>
But I always get the error
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.url
But I am achecking <% if !@attachment.blank? %> ..Is it not the right
way?If <% if !@attachment.blank? %> is true how the controll enters in
the if case above?Should it enter the else case only?Please help
You're checking @attachment.blank, but you use
@attachment.attachment.url. It looks you occasionally duplicated
"attachment". Or if you have a method "attachment" under @attachment,
you should check that for nil also (@attachment.attachment.blank?).
But I always get the error
You have a nil object when you didn’t expect it!
The error occurred while evaluating nil.url
But I am achecking <% if !@attachment.blank? %> …Is it not the right
way?If <% if !@attachment.blank? %> is true how the controll enters in
the if case above?Should it enter the else case only?Please help
Hi
I ahve a code like
<%@attachment=ServiceDeskActivityAttachment.find_by_service_desk_activity_id(@sd_activities[loop_index].id)
%>
<% if !@attachment.blank? %>
<%= puts 'is empty'%>
<td class="searchResultLineItem1">No attachment</td>
<% end %>
But I always get the error
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.url
But I am achecking <% if !@attachment.blank? %> ..Is it not the right
way?If <% if !@attachment.blank? %> is true how the controll enters in
the if case above?Should it enter the else case only?Please help
Thanks in advance
Sijo
Hi Sijo
nil is entirely diferent from blank.your page showing error as nil
so try the following
if @attachment