Doubts on validation

Hi All,
View


Student: <%= text_field "student", "fname", "size" => 40, "maxlength" => 40 %> Program: <%= options_from_collection_for_select @programs, "id", "prg_name", @student.program_id %>

Model


class Student < ActiveRecord::Base
belongs_to :program
validates_presence_of :fname, :program
end

When I have the dropdown list with the available programs, the
application doesn’t validates the text field if I try to create a record
with blank “fname”. However if remove the dropdownnlist, it checks
whether fname is present or not. Could anyone tell what I am doing wrong
here?

Thanks
Silvy Mathews

Try it with :program_id

Bob S.
http://www.railtie.net/