Class: FamilyGallery::GroupsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/family_gallery/groups_controller.rb

Instance Method Summary collapse

Methods included from BaseFamilyGalleryController

#current_ability, #current_user

Instance Method Details

#createObject



20
21
22
23
24
25
26
# File 'app/controllers/family_gallery/groups_controller.rb', line 20

def create
  if @group.save
    redirect_to @group
  else
    render :new
  end
end

#destroyObject



39
40
41
42
43
44
45
46
# File 'app/controllers/family_gallery/groups_controller.rb', line 39

def destroy
  if @group.destroy
    redirect_to groups_url
  else
    flash[:error] = @group.errors.full_messages.join(". ")
    redirect_to @group
  end
end

#editObject



28
29
# File 'app/controllers/family_gallery/groups_controller.rb', line 28

def edit
end

#indexObject



4
5
6
7
8
9
10
11
12
# File 'app/controllers/family_gallery/groups_controller.rb', line 4

def index
  @ransack_values = params[:q] || {}
  @ransack = FamilyGallery::Group.ransack(@ransack_values)

  @groups = @ransack.result.accessible_by(current_ability)
  @groups = @groups.order(:id) unless @ransack_values[:s]
  @groups = @groups.page(params[:page])
  @groups = @groups.select { |group| can?(:show, group) }
end

#newObject



17
18
# File 'app/controllers/family_gallery/groups_controller.rb', line 17

def new
end

#showObject



14
15
# File 'app/controllers/family_gallery/groups_controller.rb', line 14

def show
end

#updateObject



31
32
33
34
35
36
37
# File 'app/controllers/family_gallery/groups_controller.rb', line 31

def update
  if @group.update_attributes(group_params)
    redirect_to @group
  else
    render :edit
  end
end