Class: Scholarship::ProgramsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Applicat::Mvc::Controller::Resource, BaseController
Defined in:
app/controllers/scholarship/programs_controller.rb

Instance Method Summary collapse

Methods included from BaseController

#application_navigation, #navigation_product_name, #navigation_product_path

Instance Method Details

#createObject



23
24
25
26
27
28
29
30
31
# File 'app/controllers/scholarship/programs_controller.rb', line 23

def create
  @program = Scholarship::Program.new(params[:scholarship_program])
  
  if @program.save
    redirect_to @program, notice: t('general.form.successfully_created')
  else
    render :new
  end
end

#destroyObject



44
45
46
47
# File 'app/controllers/scholarship/programs_controller.rb', line 44

def destroy
  @program.destroy
  redirect_to organization_scholarship_programs_path(@program.organization), notice: t('general.form.destroyed')
end

#editObject



33
34
# File 'app/controllers/scholarship/programs_controller.rb', line 33

def edit
end

#indexObject



11
12
13
14
15
# File 'app/controllers/scholarship/programs_controller.rb', line 11

def index
  @organization = find_parent Scholarship::Program::PARENT_TYPES
  @programs = @organization ? @organization.scholarship_programs.order(:name) : Scholarship::Program.order(:name)
  @programs = @programs.paginate(page: params[:page], per_page: 25)
end

#newObject



20
21
# File 'app/controllers/scholarship/programs_controller.rb', line 20

def new
end

#resourceObject



49
50
51
# File 'app/controllers/scholarship/programs_controller.rb', line 49

def resource
  @program
end

#showObject



17
18
# File 'app/controllers/scholarship/programs_controller.rb', line 17

def show
end

#updateObject



36
37
38
39
40
41
42
# File 'app/controllers/scholarship/programs_controller.rb', line 36

def update
  if @program.update_attributes(params[:scholarship_program])
    redirect_to @program, notice: t('general.form.successfully_updated')
  else
    render :edit
  end
end