Class: Geography::StatesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/geography/states_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /states



26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/geography/states_controller.rb', line 26

def create
  authorize! :create, @state
  @state = State.new(state_params)

  if @state.save
    redirect_to @state, notice: 'State was successfully created.'
  else
    render :new
  end
end

#destroyObject

DELETE /states/1



47
48
49
50
# File 'app/controllers/geography/states_controller.rb', line 47

def destroy
  @state.destroy
  redirect_to states_url, notice: 'State was successfully destroyed.'
end

#editObject

GET /states/1/edit



22
23
# File 'app/controllers/geography/states_controller.rb', line 22

def edit
end

#indexObject

GET /states



8
9
10
# File 'app/controllers/geography/states_controller.rb', line 8

def index
  @states = State.all.order(:name)
end

#newObject

GET /states/new



17
18
19
# File 'app/controllers/geography/states_controller.rb', line 17

def new
  @state = State.new
end

#showObject

GET /states/1



13
14
# File 'app/controllers/geography/states_controller.rb', line 13

def show
end

#updateObject

PATCH/PUT /states/1



38
39
40
41
42
43
44
# File 'app/controllers/geography/states_controller.rb', line 38

def update
  if @state.update(state_params)
    redirect_to @state, notice: 'State was successfully updated.'
  else
    render :edit
  end
end