Class: UnitsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- UnitsController
- Defined in:
- app/controllers/units_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /units POST /units.json.
-
#destroy ⇒ Object
DELETE /units/1 DELETE /units/1.json.
-
#edit ⇒ Object
GET /units/1/edit.
-
#index ⇒ Object
GET /units GET /units.json.
-
#new ⇒ Object
GET /units/new.
-
#show ⇒ Object
GET /units/1 GET /units/1.json.
-
#update ⇒ Object
PATCH/PUT /units/1 PATCH/PUT /units/1.json.
Instance Method Details
#create ⇒ Object
POST /units POST /units.json
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/units_controller.rb', line 26 def create @unit = Unit.new(unit_params) respond_to do |format| if @unit.save format.html { redirect_to @unit, notice: 'Unit was successfully created.' } format.json { render action: 'show', status: :created, location: @unit } else format.html { render action: 'new' } format.json { render json: @unit.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /units/1 DELETE /units/1.json
56 57 58 59 60 61 62 |
# File 'app/controllers/units_controller.rb', line 56 def destroy @unit.destroy respond_to do |format| format.html { redirect_to units_url } format.json { head :no_content } end end |
#edit ⇒ Object
GET /units/1/edit
21 22 |
# File 'app/controllers/units_controller.rb', line 21 def edit end |
#index ⇒ Object
GET /units GET /units.json
6 7 8 |
# File 'app/controllers/units_controller.rb', line 6 def index @units = Unit.all end |
#new ⇒ Object
GET /units/new
16 17 18 |
# File 'app/controllers/units_controller.rb', line 16 def new @unit = Unit.new end |
#show ⇒ Object
GET /units/1 GET /units/1.json
12 13 |
# File 'app/controllers/units_controller.rb', line 12 def show end |
#update ⇒ Object
PATCH/PUT /units/1 PATCH/PUT /units/1.json
42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/units_controller.rb', line 42 def update respond_to do |format| if @unit.update(unit_params) format.html { redirect_to @unit, notice: 'Unit was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @unit.errors, status: :unprocessable_entity } end end end |