Class: Bootsy::ImagesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/bootsy/images_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



23
24
25
26
27
28
# File 'app/controllers/bootsy/images_controller.rb', line 23

def create
  @gallery.save!
  @image = @gallery.images.new(image_params)

  create_and_respond
end

#destroyObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/bootsy/images_controller.rb', line 30

def destroy
  @image = Image.find(params[:id])
  @image.destroy

  respond_to do |format|
    format.json do
      render json: { id: params[:id] }
    end

    format.html { redirect_to images_url }
  end
end

#indexObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/bootsy/images_controller.rb', line 8

def index
  @images = @gallery.images

  respond_to do |format|
    format.html # index.html.erb

    format.json do
      render json: {
        images: @images.map { |image| image_markup(image) },
        form: new_image_markup(@gallery)
      }
    end
  end
end