Class: CourseCategoriesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/course_categories_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

post /course_categories



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

def create
  @entity = CourseCategory.new(creation_parameters)
  if @entity.save
    next_page = admin_course_category_path(@entity.id)
    respond_to do |format|
      format.html { redirect_to(next_page) }
      format.json { render json: { links: { self: next_page } } }
      format.js { render(js: "document.location.href = '#{next_page}'") }
    end
  else
    render :new, status: :bad_request
  end
end

#destroyObject

delete /course_categories/:id



56
57
58
59
60
61
# File 'app/controllers/course_categories_controller.rb', line 56

def destroy
  if @entity.destroy
    flash[:notice] = t('course_categories.destroy.success')
  end
  redirect_to(admin_course_categories_path)
end

#editObject

get /course_categories/:id/edit



38
39
# File 'app/controllers/course_categories_controller.rb', line 38

def edit
end

#indexObject

get /course_categories



9
10
# File 'app/controllers/course_categories_controller.rb', line 9

def index
end

#newObject

get /course_categories/new



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

def new
  @entity = CourseCategory.new
end

#showObject

get /course_categories/:id



33
34
35
# File 'app/controllers/course_categories_controller.rb', line 33

def show
  @collection = @entity.courses.page_for_visitors(current_page)
end

#updateObject

patch /course_categories/:id



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

def update
  if @entity.update entity_parameters
    next_page = admin_course_category_path(@entity.id)
    respond_to do |format|
      format.html { redirect_to(next_page, notice: t('course_categories.update.success')) }
      format.json { render json: { links: { self: next_page } } }
      format.js { render(js: "document.location.href = '#{next_page}'") }
    end
  else
    render :edit, status: :bad_request
  end
end