Class: Course::Material::MaterialsController

Inherits:
Controller show all
Defined in:
app/controllers/course/material/materials_controller.rb

Instance Method Summary collapse

Methods included from ApplicationSignInCallbacksConcern

#sign_in

Methods included from ApplicationPaginationConcern

#page_param

Methods included from ApplicationAnnouncementsConcern

#global_announcements, #unread_global_announcements

Methods included from ApplicationInstanceUserConcern

#current_instance_user

Methods included from ApplicationUserTimeZoneConcern

#set_time_zone

Methods included from ApplicationUserConcern

#handle_access_denied, #publicly_accessible?

Methods included from ApplicationComponentsConcern

#handle_component_not_found

Instance Method Details

#destroyObject


22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/course/material/materials_controller.rb', line 22

def destroy
  if @material.destroy
    respond_to do |format|
      format.html do
        redirect_to course_material_folder_path(current_course, @folder),
                    success: t('.success', name: @material.name)
      end
      format.json { head :ok }
    end
  else
    redirect_to course_material_folder_path(current_course, @folder),
                danger: t('.failure', message: @material.errors.full_messages.to_sentence)
  end
end

#editObject


10
11
# File 'app/controllers/course/material/materials_controller.rb', line 10

def edit
end

#showObject


5
6
7
8
# File 'app/controllers/course/material/materials_controller.rb', line 5

def show
  authorize!(:read_owner, @material.folder)
  redirect_to @material.attachment.url(filename: @material.name)
end

#updateObject


13
14
15
16
17
18
19
20
# File 'app/controllers/course/material/materials_controller.rb', line 13

def update
  if @material.update_attributes(material_params)
    redirect_to course_material_folder_path(current_course, @folder),
                success: t('.success', name: @material.name)
  else
    render 'edit'
  end
end