Class: Geography::CitiesController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /cities



29
30
31
32
33
34
35
36
37
# File 'app/controllers/geography/cities_controller.rb', line 29

def create
  authorize! :create, @city
  @city = City.new(city_params)
  if @city.save
    redirect_to @city, notice: 'City was successfully created.'
  else
    render :new
  end
end

#destroyObject

DELETE /cities/1



49
50
51
52
# File 'app/controllers/geography/cities_controller.rb', line 49

def destroy
  @city.destroy
  redirect_to cities_url, notice: 'City was successfully destroyed.'
end

#editObject

GET /cities/1/edit



25
26
# File 'app/controllers/geography/cities_controller.rb', line 25

def edit
end

#indexObject

add_breadcrumb ‘Cidades’, :cities_path add_breadcrumb ‘Criar nova cidade’, ”, :only => [:new, :create] add_breadcrumb ‘Editar nova cidade’, ”, :only => [:edit, :update] GET /cities



10
11
12
# File 'app/controllers/geography/cities_controller.rb', line 10

def index
  @cities = City.all.order(:name).page(params[:page])
end

#newObject

GET /cities/new



20
21
22
# File 'app/controllers/geography/cities_controller.rb', line 20

def new
  @city = City.new
end

#showObject

GET /cities/1



15
16
17
# File 'app/controllers/geography/cities_controller.rb', line 15

def show
 # add_breadcrumb @city.name, ''
end

#updateObject

PATCH/PUT /cities/1



40
41
42
43
44
45
46
# File 'app/controllers/geography/cities_controller.rb', line 40

def update
  if @city.update(city_params)
    redirect_to @city, notice: 'City was successfully updated.'
  else
    render :edit
  end
end