Class: SponsoredProjectSponsorsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/sponsored_project_sponsors_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#robot?

Instance Method Details

#archiveObject


42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/sponsored_project_sponsors_controller.rb', line 42

def archive
  authorize! :archive, SponsoredProjectSponsor
  @sponsor = SponsoredProjectSponsor.find(params[:id])
  if @sponsor.update_attributes({:is_archived => true})
    flash[:notice] = 'Sponsor was successfully archived.'
    redirect_to(sponsored_projects_path)
  else
    flash[:notice] = 'Sponsor could not be archived.'
    redirect_to(sponsored_projects_path)
  end
end

#createObject


18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/sponsored_project_sponsors_controller.rb', line 18

def create
  authorize! :create, SponsoredProjectSponsor
  @sponsor = SponsoredProjectSponsor.new(params[:sponsored_project_sponsor])

  if @sponsor.save
    flash[:notice] = 'Sponsor was successfully created.'
    redirect_back_or_default(sponsored_projects_path)
  else
    render "new"
  end
end

#editObject


13
14
15
16
# File 'app/controllers/sponsored_project_sponsors_controller.rb', line 13

def edit
  authorize! :update, SponsoredProjectSponsor
  @sponsor = SponsoredProjectSponsor.find(params[:id])
end

#newObject


7
8
9
10
11
# File 'app/controllers/sponsored_project_sponsors_controller.rb', line 7

def new
  authorize! :create, SponsoredProjectSponsor
  store_previous_location
  @sponsor = SponsoredProjectSponsor.new
end

#updateObject


30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/sponsored_project_sponsors_controller.rb', line 30

def update
  authorize! :update, SponsoredProjectSponsor
  @sponsor = SponsoredProjectSponsor.find(params[:id])

  if @sponsor.update_attributes(params[:sponsored_project_sponsor])
    flash[:notice] = 'Sponsor was successfully updated.'
    redirect_to(sponsored_projects_path)
  else
    render "edit"
  end
end