Class: PixesController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /pixes POST /pixes.json


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/pixes_controller.rb', line 26

def create
  @pix = Pix.new(pix_params)

  respond_to do |format|
    @pix.images.attach(params[:images]) if params[:images]
    if @pix.save
      format.html do
        redirect_to go_to_pix(@pix),
                    notice: 'pix was successfully created.'
      end
      format.json { render :show, status: :created, location: @pix }
    else
      format.html { render :new }
      format.json { render json: @pix.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /pixes/1 DELETE /pixes/1.json


64
65
66
67
68
69
70
# File 'app/controllers/pixes_controller.rb', line 64

def destroy
  @pix.destroy
  respond_to do |format|
    format.html { redirect_to pixes_url, notice: 'pix was successfully destroyed.' }
    format.json { head :no_content }
  end
end

#editObject

GET /pixes/1/edit


21
22
# File 'app/controllers/pixes_controller.rb', line 21

def edit
end

#indexObject

GET /pixs GET /pixs.json


6
7
8
# File 'app/controllers/pixes_controller.rb', line 6

def index
  @pixs = Pix.all
end

#newObject

GET /pixes/new


16
17
18
# File 'app/controllers/pixes_controller.rb', line 16

def new
  @pix = Pix.new
end

#showObject

GET /pixes/1 GET /pixes/1.json


12
13
# File 'app/controllers/pixes_controller.rb', line 12

def show
end

#updateObject

PATCH/PUT /pixes/1 PATCH/PUT /pixes/1.json


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/controllers/pixes_controller.rb', line 46

def update
  respond_to do |format|
    @pix.images.attach(params[:images]) if params[:images]
    if @pix.update(pix_params)
      format.html do
        redirect_to go_to_pix(@pix),
                    notice: 'pix was successfully updated.'
      end
      format.json { render :show, status: :ok, location: @pix }
    else
      format.html { render :edit }
      format.json { render json: @pix.errors, status: :unprocessable_entity }
    end
  end
end