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 ><a href="<%=h @attachment.attachment.url %>"
target="_blank">Attachment</a> <a
href=''#''onmouseover="Tip(''<%=h
@attachment.attachment %>'',LEFT, true,
CLOSEBTN,false,FADEOUT,1000, SHADOW,true, STICKY,false, WIDTH,300
)">File Name</a></td>
<% else %>
<%= puts ''is not 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
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
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?). LoKi. On 30 июл, 08:35, Sijo Kg <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi > I ahve a code like > <%@attachment=ServiceDeskActivityAttachment.find_by_service_desk_activity_i-d(@sd_activities[loop_index].id) > %> > <% if !...@attachment.blank? %> > <%= puts ''is empty''%> > > <td ><a href="<%=h @attachment.attachment.url %>" target="_blank">Attachment</a> <a > > href=''#''onmouseover="Tip(''<%=h @attachment.attachment %>'',LEFT, true, > CLOSEBTN,false,FADEOUT,1000, SHADOW,true, STICKY,false, WIDTH,300 > )">File Name</a></td> > <% else %> > <%= puts ''is not 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 > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
2008/7/30, Sijo Kg <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > > 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 ><a href="<%=h @attachment.attachment.url %>" target="_blank" > >Attachment</a> <a > href=''#''onmouseover="Tip(''<%=h @attachment.attachment %>'',LEFT, true, > CLOSEBTN,false,FADEOUT,1000, SHADOW,true, STICKY,false, WIDTH,300 > )">File Name</a></td> > <% else %> > <%= puts ''is not 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 > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi
I have already checked as u said
if @attachment
--------------
end
But getting the same error
Sijo
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
The attachment method on attachment is returning nil, not the @attachment variable itself. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---