Charlie
2006-Apr-12 12:35 UTC
[Rails] How to get validates_presence_of worked in this situation?
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 -- Posted via http://www.ruby-forum.com/.
Seemingly Similar Threads
- Am I going too far or Rails is just confusing? was {validates_presence_of *_id attributes}
- Not appear error message
- [Rails Heroku] Problem with saving object (on heroku hosting)
- Polymorphism, acts_as_relation gem and nested attributes
- validates_presence_of not working