Class: MediaGallery::GalleriesController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- MediaGallery::GalleriesController
- Defined in:
- app/controllers/media_gallery/galleries_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /galleries.
-
#destroy ⇒ Object
DELETE /galleries/1.
-
#index ⇒ Object
GET /galleries.
-
#show ⇒ Object
GET /galleries/1.
-
#update ⇒ Object
PATCH/PUT /galleries/1.
Methods inherited from ApplicationController
#create_ability, #current_ability, #current_user
Instance Method Details
#create ⇒ Object
POST /galleries
16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/media_gallery/galleries_controller.rb', line 16 def create @gallery = Gallery.new( name: gallery_params[:name], ownable: current_user, description: gallery_params[:description] ) :create, @gallery @gallery.save! end |
#destroy ⇒ Object
DELETE /galleries/1
38 39 40 |
# File 'app/controllers/media_gallery/galleries_controller.rb', line 38 def destroy @gallery.destroy end |
#index ⇒ Object
GET /galleries
9 10 11 12 13 |
# File 'app/controllers/media_gallery/galleries_controller.rb', line 9 def index raise CanCan::AccessDenied.new unless current_user @galleries = Gallery.where(ownable: current_user).order(name: :asc) :read, @galleries[0] if @galleries.length > 0 end |
#show ⇒ Object
GET /galleries/1
27 28 29 |
# File 'app/controllers/media_gallery/galleries_controller.rb', line 27 def show :read, @gallery end |
#update ⇒ Object
PATCH/PUT /galleries/1
32 33 34 35 |
# File 'app/controllers/media_gallery/galleries_controller.rb', line 32 def update :update, @gallery @gallery.update_attributes!(gallery_params) end |