summaryrefslogtreecommitdiff
path: root/app/controllers/groups_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/groups_controller.rb')
-rw-r--r--app/controllers/groups_controller.rb52
1 files changed, 52 insertions, 0 deletions
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
new file mode 100644
index 0000000..74ad7c8
--- /dev/null
+++ b/app/controllers/groups_controller.rb
@@ -0,0 +1,52 @@
+class GroupsController < ApplicationController
+ load_and_authorize_resource :group
+ before_filter :spread_breadcrumbs
+
+ def index
+ @groups = Group.all
+ end
+
+ def show
+ @group = Group.find(params[:id])
+ end
+
+ def new
+ @group = Group.new
+ end
+
+ def create
+ @group = Group.new(params[:group])
+ if @group.save
+ redirect_to @group, :notice => t('groups.controller.successfuly_created')
+ else
+ render :new
+ end
+ end
+
+ def edit
+ @group = Group.find(params[:id])
+ end
+
+ def update
+ @group = Group.find(params[:id])
+ if @group.update_attributes(params[:group])
+ redirect_to @group, :notice => t('groups.controller.successfuly_updated')
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @group = Group.find(params[:id])
+ @group.destroy
+ redirect_to groups_url, :notice => t('groups.controller.successfuly_destroyed')
+ end
+
+ private
+ def spread_breadcrumbs
+ add_breadcrumb t("groups.index.page_title"), groups_path
+ if @group && !@group.new_record?
+ add_breadcrumb @group, @group
+ end
+ end
+end