Skip to content

Instantly share code, notes, and snippets.

@ghankerson
Created January 12, 2015 16:45
Show Gist options
  • Select an option

  • Save ghankerson/9c5f34eb547da48ec542 to your computer and use it in GitHub Desktop.

Select an option

Save ghankerson/9c5f34eb547da48ec542 to your computer and use it in GitHub Desktop.
<%= form_for(@organization) do |f| %>
<% if @organization.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@organization.errors.count, "error") %> prohibited this organization from being saved:</h2>
<ul>
<% @organization.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :name %><br>
<%= f.text_field :name ,:class => "form-control"%>
</div>
<div class="field">
<%= f.label :organization_type %><br>
<%= f.select :organization_type, %w[Partner Provider] %>
</div>
<%= ContactType.all.each do |ct| %>
<%= f.fields_for :contacts, @organization.contacts.find_or_initialize_by(contact_type_id: ct.id) do |c| %>
<fieldset>
<%# collection_select foreign key for contact_type, collection, primary key for collection, value column for collection, options %>
<%= c.collection_select(:contact_type_id, ContactType.all, :id, :contactType, prompt: true) %>
<%= c.text_field :value %>
</fieldset>
<% end %>
<% end %>
<div class="actions">
<%= f.submit :class => "button round" %>
</div>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment