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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9d069b3237bc411726d3a83d9077508d?d=identicon&s=25 Charlie (Guest)
on 2006-04-12 14:35
Suppose:
class articles < ActiveRecord::Base
  has_many :assistarticles

  validates_presence_of :body
end

class assistarticles < ActiveRecord::Base
  belongs_to :article

  validates_presence_of :detail
end

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?

Thanks
Charlie
This topic is locked and can not be replied to.