Forum: Ruby on Rails Doubts on validation

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
unknown (Guest)
on 2006-02-02 21:38
(Received via mailing list)
Hi All,
      <td><b>Student: </b></td>
      <td><%= text_field "student", "fname", "size" => 40, "maxlength"
=> 40 %></td>
      <td><b>Program: </b></td>
      <td><select id="student_program_id" name="student[program_id]">
        <%= 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
Bob S. (Guest)
on 2006-02-03 01:40
(Received via mailing list)
Try it with :program_id

Bob S.
This topic is locked and can not be replied to.