Class: OCms::ImagesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- OCms::ImagesController
- Defined in:
- app/controllers/o_cms/images_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/o_cms/images_controller.rb', line 28 def create @image = Image.new(image_params) if @image.save flash[:notice] = "Image was saved successfully." redirect_to @image else flash.now[:alert] = "Error creating image. Please try again." render :new end end |
#destroy ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/o_cms/images_controller.rb', line 57 def destroy @image = Image.find(params[:id]) if @image.destroy flash[:notice] = "\"#{@image.name}\" was deleted successfully." redirect_to action: :index else flash.now[:alert] = "There was an error deleting the image." render :show end end |
#edit ⇒ Object
40 41 42 |
# File 'app/controllers/o_cms/images_controller.rb', line 40 def edit @image = Image.find(params[:id]) end |
#index ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'app/controllers/o_cms/images_controller.rb', line 6 def index @images = Image.all respond_to do |format| format.html format.js end end |
#new ⇒ Object
24 25 26 |
# File 'app/controllers/o_cms/images_controller.rb', line 24 def new @image = Image.new end |
#show ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'app/controllers/o_cms/images_controller.rb', line 15 def show @image = Image.find(params[:id]) respond_to do |format| format.html format.js end end |
#update ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/o_cms/images_controller.rb', line 44 def update @image = Image.find(params[:id]) @image.assign_attributes(image_params) if @image.save flash[:notice] = "Image was updated successfully." redirect_to @image else flash.now[:alert] = "Error saving image. Please try again." render :edit end end |