# Guideline for "has\_one" validation + Multiple post actions from a form

**URL:** <https://www.ruby-forum.com/t/guideline-for-has-one-validation-multiple-post-actions-from-a-form/132139>\
**Category:** Rails\
**Created:** [March 17, 2008, 11:37am UTC](https://www.ruby-forum.com/t/guideline-for-has-one-validation-multiple-post-actions-from-a-form/132139 "2008-03-17T11:37:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gishu\_Pillai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f6c823/32.png) [@Gishu\_Pillai](https://www.ruby-forum.com/u/Gishu_Pillai)\
**Post date:** [March 17, 2008, 11:37am UTC](https://www.ruby-forum.com/t/guideline-for-has-one-validation-multiple-post-actions-from-a-form/132139/1 "2008-03-17T11:37:41Z")

</div>

Hi,  
This is my scenario. I have an expense entry form,  
each expense must have one category - classic foreign key example  
Now I see that has\_one with a non-existent category is not caught, I  
think Rails creates the new category automagically. I had to add  
custom validation to the expense model to catch that

Next what I would like is on the expense entry view/form,

- Allow the user to select a category from a drop down (easily done  
via collection\_select helper).
- Also allow him to add a new category if required. My initial idea  
was for an editable dropdown, I couldn’t find one for rails. Next I  
tried adding a textbox and a link/button to trigger an action on the  
controller.

The submit button set off the entire expense validation on a category  
add click. The link approach was not able to pass in the description  
of the new category to the controller action createCategory  
\<%= text\_select ‘category’, ‘description’ =\>  
with @category defined in the controller.

If I am not coherent… please ask questions & help me out.  
Gishu
