# Polymorphic Associations - Error-Handling?

**URL:** <https://www.ruby-forum.com/t/polymorphic-associations-error-handling/105276>\
**Category:** Rails\
**Created:** [May 28, 2007, 11:17am UTC](https://www.ruby-forum.com/t/polymorphic-associations-error-handling/105276 "2007-05-28T11:17:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![scope](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f4b2a3/32.png) [@scope](https://www.ruby-forum.com/u/scope)\
**Post date:** [May 28, 2007, 11:17am UTC](https://www.ruby-forum.com/t/polymorphic-associations-error-handling/105276/1 "2007-05-28T11:17:03Z")

</div>

Hey there,

I have used polymorphic associations to model different types of  
questions (multiple choice, simple text, etc.) I want to allow users to  
create these questions and chose a type to enter the specific data ( max  
text length for text fields, options for multiple choice questions,  
etc.)

How do I get to the errors of these question type subclasses?

This way, see 2. line, it does not work…

\<%= error\_messages\_for :question %\>  
\<%= error\_messages\_for :question.resource %\>

\<% form\_for :question, @question, :url =\> {:action =\> :new, :survey =\>  
@survey} do |form| %\>

\<%= \_( "Question" ) %\> \<%= form.text\_field :text %\>

\<% fields\_for :comment\_question, @question.resource do  
|comment\_question| %\>

\<%= \_( "Size" ) %\> \<%= comment\_question.select :size, CommentQuestion::COMMENT\_SIZE\_OPTIONS %\>

\<% end %\>

\<%= submit\_tag \_( "Create Question" ) %\>

\<% end %\>

Does anybody have an idea of how to show the errors for the resource  
objects?  
(In this example, the CommmentQuestion of course has a  
validates\_inclusion\_of :size in it!)
