Doubts on validation

Hi All,

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


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

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

Silvy Mathews

Try it with :program_id

Bob S.

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