Skip to content

Instantly share code, notes, and snippets.

@christianhager
Created October 8, 2009 13:57
Show Gist options
  • Save christianhager/205036 to your computer and use it in GitHub Desktop.
Save christianhager/205036 to your computer and use it in GitHub Desktop.
in account model:
accepts_nested_attributes_for :from_adrs, :allow_destroy => true
in from_adr model:
validates_format_of :email,
:with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i,
:message => 'email must be valid'
form:
<%form_for @account do |f|%>
<%=f.error_messages%>
<%f.fields_for :from_adrs do |f2|%>
<%=f2.text_field :email%>
<%end%>
<%=f.submit "Save"%>
<%end%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment