Skip to content

Commit

Permalink
Add invites to groups/edit, closes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
Aesthetikx committed Aug 3, 2014
1 parent c470e3b commit 28c162b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/admin/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ def company_link(company)

permit_params :street_address, :city, :first_payment_date, :final_payment_date,
:payment_address_id, :company_id,
users_groups_attributes: [:_destroy, :user_id, :id]
users_groups_attributes: [:_destroy, :user_id, :id],
invites_attributes: [:_destroy, :id]

index do
selectable_column
Expand Down Expand Up @@ -88,6 +89,10 @@ def company_link(company)
f.template.render partial: 'user_membership', locals: { f: f }
end

f.inputs "Invites" do
f.template.render partial: 'invites', locals: { f: f }
end

f.actions
end

Expand Down
1 change: 1 addition & 0 deletions app/models/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Group < ActiveRecord::Base
belongs_to :company

accepts_nested_attributes_for :users_groups, allow_destroy: true, reject_if: proc { |attributes| attributes[:user_id].blank? }
accepts_nested_attributes_for :invites, allow_destroy: true

def to_s
"#{street_address}, #{city}"
Expand Down
8 changes: 8 additions & 0 deletions app/views/admin/groups/_invite_fields.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="nested-fields">
<%= f.object.email %>
<fieldset class="actions">
<li class="cancel">
<%= link_to_remove_association "Remove Invite", f %>
</li>
</fieldset>
</div>
5 changes: 5 additions & 0 deletions app/views/admin/groups/_invites.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div id="invites">
<%= f.semantic_fields_for :invites do |inf| %>
<% render 'invite_fields', f: inf %>
<% end %>
</div>

0 comments on commit 28c162b

Please sign in to comment.