Forum: Ruby on Rails How to get validates_presence_of worked in this situation?

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.
Charlie (Guest)
on 2006-04-12 16:35
class articles < ActiveRecord::Base
  has_many :assistarticles

  validates_presence_of :body

class assistarticles < ActiveRecord::Base
  belongs_to :article

  validates_presence_of :detail

In the submit form:
  <%= text_field 'article', 'body'  %>
  <%= text_field 'assistarticle', 'detail'  %>

The process logic will be done in article_controller
Now if the article.body field is empty,then validates_presence_of will
work and return the error to let user re-enter the body content,but if
the assistarticles.detail is empty,then no tips at all,and the
accordingly record will not be stored,either.  How to let the latter
validates_presence_of work?

This topic is locked and can not be replied to.