rails f.submit checking another table -


i understand in form_for, i'm able validate form's table in model, if wanted validate "f.submit"ted data against table?

specifically, staff can checkout radio in checkout model/table if both staff , radio exists in own respective tables.

how go passing in staff , radio table checkout validation criteria?

thanks!

forms in rails not linked validation (not in same way symfony2) display error messages.

you can nest resources in forms fields_for used accepts_nested_attributes_for.

<%= form_for(@member) |f| %>   <%= f.text_field(:name) %>       <%= fields_for :avatar, @member.avatar |avatar_fields| %>     <%= avatar_fields.text :url %>   <% end %> <% end %>  class member < activerecord::base   has_one :avatar   accepts_nested_attributes_for :avatar end 

you can create validation model association validates_associated or passing validates: true when declaring association. see this question details.

class member < activerecord::base   has_one :avatar, validate: true   accepts_nested_attributes_for :avatar   # or   # validates_associated :avatar end 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -