Validation fails with select option list

I have a form with some text_field and some drop down lists.



Program:


<%= options_from_collection_for_select @programs, “id”, “prg_name”,
@student.program_id %>

I am not able to use validates_presence_of in the model whenever I am
including this options_from_collection_for_select list. If I remove that
it checks for the presence of the field. Otherwise, it gives me the
following error
You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.inject

Extracted source (around line #18):

17:

Program:

18: <%= options_from_collection_for_select @programs, “id”,
“prg_name”, @student.program_id %>
19:
20:
21:

What is the reason for this?

Any help appreciated.
Thanks
Silvy Mathews

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs