# Models/tables with relationships and forms

**URL:** <https://www.ruby-forum.com/t/models-tables-with-relationships-and-forms/113984>\
**Category:** Rails\
**Created:** [September 6, 2007, 9:30pm UTC](https://www.ruby-forum.com/t/models-tables-with-relationships-and-forms/113984 "2007-09-06T21:30:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arnfinn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c5a1d2/32.png) [@Arnfinn](https://www.ruby-forum.com/u/Arnfinn)\
**Post date:** [September 6, 2007, 9:30pm UTC](https://www.ruby-forum.com/t/models-tables-with-relationships-and-forms/113984/1 "2007-09-06T21:30:06Z")

</div>

Hi, I’m just starting out writing a RoR application, and I have a  
couple of questions…

Lets say I have a model  
class Questionnaire \< ActiveRecord::Base  
has\_many :categories  
end

I’ve understood that one can reference a variable from the model/table  
in a form using e.g.  
\<%= text\_field ‘questionnaire’, ‘title’ %\>

But what if I want to do the same with the related model Category?  
Using  
\<%= text\_field(‘category’, ‘caption’) %\>  
does not give any information about which questionnaire the category  
belongs to. Are there any neat tricks to do this within the framework,  
lets say something like  
\<%= text\_field(‘questionnaire\_category\_123’, ‘caption’) %\>  
or must I write some custom code to do this?

And what about validations: using validates\_\* now only reports that  
something is wrong within Categories when i try to do  
“some\_questionnaire.save”, but does not give me any specific  
information about what failed to validate. How can I get that sort of  
information?

Any help is greatly appreciated!

Best,  
Arnfinn
