Class: ChainsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#home, #mining_profile, #privacy_policy, #terms

Instance Method Details

#createObject

POST /chains or /chains.json



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/chains_controller.rb', line 25

def create
  @chain = Chain.new(chain_params)

  respond_to do |format|
    if @chain.save
      format.html { redirect_to chain_url(@chain), notice: "Chain was successfully created." }
      format.json { render :show, status: :created, location: @chain }
    else
      format.html { render :new, status: :unprocessable_entity }
      format.json { render json: @chain.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /chains/1 or /chains/1.json



53
54
55
56
57
58
59
60
# File 'app/controllers/chains_controller.rb', line 53

def destroy
  @chain.destroy

  respond_to do |format|
    format.html { redirect_to chains_url, notice: "Chain was successfully destroyed." }
    format.json { head :no_content }
  end
end

#editObject

GET /chains/1/edit



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

def edit
end

#indexObject

GET /chains or /chains.json



7
8
9
# File 'app/controllers/chains_controller.rb', line 7

def index
  @chains = Chain.all
end

#newObject

GET /chains/new



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

def new
  @chain = Chain.new
end

#showObject

GET /chains/1 or /chains/1.json



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

def show
end

#updateObject

PATCH/PUT /chains/1 or /chains/1.json



40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/chains_controller.rb', line 40

def update
  respond_to do |format|
    if @chain.update(chain_params)
      format.html { redirect_to chain_url(@chain), notice: "Chain was successfully updated." }
      format.json { render :show, status: :ok, location: @chain }
    else
      format.html { render :edit, status: :unprocessable_entity }
      format.json { render json: @chain.errors, status: :unprocessable_entity }
    end
  end
end