mahmoud said wrote: > On Wed, Dec 3, 2008 at 4:30 PM, Martyn Elmy-liddiard < > [EMAIL PROTECTED]> wrote: > >> Thanks Fred but I still get an error:- >> .......etc >> >> >> and the error I get is:- >> >> You have a nil object when you didn't expect it! >> The error occured while evaluating nil.year >> -- > > > That's because @risks.LastReviewed is the one that is nil > use > <option value="<%= @risks.LastReviewed.year if @risks.LastReviewed%>" > selected="selected"> > > > -- > Mahmoud Said > Software Developer > blog.modsaid.com > www.eSpace.com.eg > +20-16-1223857
Mahmoud, Still not quite seeing why @risks.LastReviewed can be checked for existance but @risks.LastReviewed.year cant be. I would have thought an element of the date would be able to be checked in the same way as the whole date. Anyhow...you help was great and has allowed me to sort the problem so thanks very much indeed. Just for anyone else....I also needed to put the existance check in the displayed element of the drop-down selection thus:- <option value="<%= @risks.LastReviewed.year if @risks.LastReviewed%>" selected="selected"><%= @risks.LastReviewed.year if @risks.LastReviewed%></option> Martyn -- 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 [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

