Class: CourseCategoriesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- CourseCategoriesController
- Defined in:
- app/controllers/course_categories_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
post /course_categories.
-
#destroy ⇒ Object
delete /course_categories/:id.
-
#edit ⇒ Object
get /course_categories/:id/edit.
-
#index ⇒ Object
get /course_categories.
-
#new ⇒ Object
get /course_categories/new.
-
#show ⇒ Object
get /course_categories/:id.
-
#update ⇒ Object
patch /course_categories/:id.
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
get /course_categories/:id/edit
38 39 |
# File 'app/controllers/course_categories_controller.rb', line 38 def edit end |
#index ⇒ Object
get /course_categories
9 10 |
# File 'app/controllers/course_categories_controller.rb', line 9 def index end |
#new ⇒ Object
get /course_categories/new
13 14 15 |
# File 'app/controllers/course_categories_controller.rb', line 13 def new @entity = CourseCategory.new end |
#show ⇒ Object
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 |
#update ⇒ Object
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 |