Gishu Pillai
2008-Mar-17 10:36 UTC
guideline for "has_one" validation + Multiple post actions from a form
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---