AntonAL
AntonAL

Reputation: 17430

validates_associated and HABTM

Article HABTM authors

In Article model, i say:

validates_associated :authors

But, by creating of the new Article, this validation does't happen, because i don't see the errors.

Another errors are displayed properly, but this.

I render errors so:

<div class="errors">
    <%= article_form.error_messages %>
</div>

What's wrong here ?

Upvotes: 0

Views: 264

Answers (1)

Yannis
Yannis

Reputation: 5426

Validates_associated should work with any kind of association. Try to display your errors either with:

<%= @article.errors.full_messages.to_sentence %>

or

<%- for author in @article.authors %>
  <%= author.errors.full_messages.to_sentence %>
<%- end %>

Upvotes: 1

Related Questions