From 2a9b798f9e122582abb36605a7d4a1da0e70eca9 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 22 Feb 2013 07:08:23 -0500 Subject: pickup group permission model added --- app/controllers/groups_controller.rb | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 app/controllers/groups_controller.rb (limited to 'app/controllers/groups_controller.rb') diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb new file mode 100644 index 0000000..1ab7a4f --- /dev/null +++ b/app/controllers/groups_controller.rb @@ -0,0 +1,49 @@ +class GroupsController < ApplicationController + 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 -- cgit v1.2.3 From 0eb056b92e9eaf091146c13dcb3fdc9d7fb34baf Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 22 Feb 2013 13:08:46 -0500 Subject: breadcrumbs --- app/controllers/groups_controller.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'app/controllers/groups_controller.rb') diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 1ab7a4f..74ad7c8 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -1,4 +1,7 @@ class GroupsController < ApplicationController + load_and_authorize_resource :group + before_filter :spread_breadcrumbs + def index @groups = Group.all end -- cgit v1.2.3