Class: Guts::MediaController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Guts::MediaController
- Defined in:
- app/controllers/guts/media_controller.rb
Overview
Media controller
Instance Method Summary collapse
-
#create ⇒ Object
Creates a medium through post.
-
#destroy ⇒ Object
Destroys a medium.
-
#edit ⇒ Object
Editing for a medium.
-
#editor_insert ⇒ Object
Handles showing the insert medium allowing TinyMce to use it.
-
#index ⇒ Object
Displays a list of media.
-
#new ⇒ Object
Creation of a new medium.
-
#show ⇒ Object
Shows details about a single medium.
-
#update ⇒ Object
Updates a medium through patch.
Methods included from MultisiteConcern
#current_site, #with_current_site
Methods included from SessionsHelper
#current_user, #log_in, #log_out, #logged_in?
Instance Method Details
#create ⇒ Object
Redirects to #index if successfull or re-renders #new if not
Creates a medium through post
35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/guts/media_controller.rb', line 35 def create @medium = Medium.new medium_params if @medium.save flash[:notice] = 'Media was successfully created.' redirect_to polymorphic_path([@object, :media]) else render :new end end |
#destroy ⇒ Object
Redirects to #index on success
Destroys a medium
59 60 61 62 63 64 |
# File 'app/controllers/guts/media_controller.rb', line 59 def destroy @medium.destroy flash[:notice] = 'Media was successfully destroyed.' redirect_to polymorphic_path([@object, :media]) end |
#edit ⇒ Object
Editing for a medium
30 31 |
# File 'app/controllers/guts/media_controller.rb', line 30 def edit end |
#editor_insert ⇒ Object
Handles showing the insert medium allowing TinyMce to use it
68 69 70 |
# File 'app/controllers/guts/media_controller.rb', line 68 def editor_insert render :editor_insert, layout: false end |
#index ⇒ Object
Depending on the object passed (polymorphic)
Displays a list of media
12 13 14 15 16 17 18 |
# File 'app/controllers/guts/media_controller.rb', line 12 def index @media = if @object @object.media.paginate(page: params[:page], per_page: @per_page) else Medium.paginate(page: params[:page], per_page: @per_page) end end |
#new ⇒ Object
Creation of a new medium
25 26 27 |
# File 'app/controllers/guts/media_controller.rb', line 25 def new @medium = Medium.new end |
#show ⇒ Object
Shows details about a single medium
21 22 |
# File 'app/controllers/guts/media_controller.rb', line 21 def show end |
#update ⇒ Object
Redirects to #index if successfull or re-renders #edit if not
Updates a medium through patch
48 49 50 51 52 53 54 55 |
# File 'app/controllers/guts/media_controller.rb', line 48 def update if @medium.update(medium_params) flash[:notice] = 'Media was successfully updated.' redirect_to polymorphic_path([@object, :media]) else render :edit end end |