summaryrefslogtreecommitdiff
path: root/app/controllers/group_memberships_controller.rb
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-02-22 07:08:23 -0500
committerPeter Kozak <spag@golwen.net>2013-02-22 07:08:23 -0500
commit2a9b798f9e122582abb36605a7d4a1da0e70eca9 (patch)
tree45fe362d677cb243fba57dc7c0c23d01e653863e /app/controllers/group_memberships_controller.rb
parentd6009d77ffa221c14a4536be98a04e8e4b6474a9 (diff)
pickup group permission model added
Diffstat (limited to 'app/controllers/group_memberships_controller.rb')
-rw-r--r--app/controllers/group_memberships_controller.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/app/controllers/group_memberships_controller.rb b/app/controllers/group_memberships_controller.rb
new file mode 100644
index 0000000..df9f6b3
--- /dev/null
+++ b/app/controllers/group_memberships_controller.rb
@@ -0,0 +1,51 @@
+class GroupMembershipsController < ApplicationController
+ load_and_authorize_resource :group
+ load_and_authorize_resource :group_membership, :through => [:group]
+
+ def index
+ end
+
+ def show
+ end
+
+ def new
+ end
+
+ def create
+ if params[:group_membership][:item_type].blank?
+ params[:group_membership][:item_type] = @group.group_memberships.first.item_type
+ end
+ @group_membership = @group.group_memberships.new(params[:group_membership])
+ if @group_membership.save
+ redirect_to action: "index", :notice => t('group_memberships.controller.successfuly_created')
+ else
+ render :new
+ end
+ end
+
+ def edit
+ end
+
+ def update
+ if @group_membership.update_attributes(params[:group_membership])
+ redirect_to action: "index", :notice => t('group_memberships.controller.successfuly_updated')
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @group_membership.destroy
+ redirect_to action: "index", :notice => t('group_memberships.controller.successfuly_destroyed')
+ end
+
+ private
+ def spread_breadcrumbs
+ add_breadcrumb t("groups.index.page_title"), groups_path
+ add_breadcrumb @group, group_path(@group)
+ add_breadcrumb t("group_memberships.index.page_title"), group_group_memberships_path(@group)
+ if @group_membership && !@group_membership.new_record?
+ add_breadcrumb @group_membership, group_group_membership_path(@group, @group_membership)
+ end
+ end
+end