On Wed, Dec 3, 2008 at 4:30 PM, Martyn Elmy-liddiard <
[EMAIL PROTECTED]> wrote:

>
> Frederick Cheung wrote:
> > On Dec 3, 1:59?pm, Martyn Elmy-liddiard <[EMAIL PROTECTED]
> > s.net> wrote:
> >>
> > don't think you need anything more than if docv.policy
> >
> > Fred
>
>
> Thanks Fred but I still get an error:-
>
> I gave a vey simple example and it may be fairer to give a slightly
> different example that I am working on where the potential nil value is
> the default selected value of a drop-down list:-
>
> <tr>
> <td><select name="risk[LastReviewed(1i)]">
> <option value="<%= @risks.LastReviewed.year if @risks.LastReviewed.year
> %>" selected="selected"><%= @risks.LastReviewed.year %></option>
> <option value="2008">2008</option>
> .......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">



>
> Posted via http://www.ruby-forum.com/.
>
> >
>


-- 
Mahmoud Said
Software Developer
blog.modsaid.com
www.eSpace.com.eg
+20-16-1223857

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to