class Admin::GroupsController

Public Instance Methods

create() click to toggle source
# File app/controllers/admin/groups_controller.rb, line 37
def create
  @group = Group.new(group_params)
  current_user.add @group
  if @group.save
    redirect_to groups_path, notice: 'Group created'
  else #
    flash.now[:error] = "Group can't be saved, because #{@group.errors.full_messages.join(' and ')}"
    render 'new'
  end
end
destroy() click to toggle source
# File app/controllers/admin/groups_controller.rb, line 23
def destroy
  @group = Group.find(params[:id])
  if @group.destroy
    redirect_to groups_path #, notice: 'Group deleted'
  else
    flash.now[:error] = "Group can't be deleted, because #{@group.errors.full_messages.join(' and ')}."
    render 'edit'
  end
end
edit() click to toggle source
# File app/controllers/admin/groups_controller.rb, line 8
def edit
  @group = Group.find(params[:id])
end
index() click to toggle source
# File app/controllers/admin/groups_controller.rb, line 4
def index
  @groups = current_user.groups
end
new() click to toggle source
# File app/controllers/admin/groups_controller.rb, line 33
def new
  @group = Group.new
end
update() click to toggle source
# File app/controllers/admin/groups_controller.rb, line 12
def update
  @group = Group.find(params[:id])
  @group.update_attributes group_params
  if @group.save
    redirect_to groups_path #, notice: 'Group saved'
  else
    flash.now[:error] = "Group can't be saved, because #{@group.errors.full_messages.join(' and ')}"
    render 'edit'
  end
end