Class: Stay::Admin::CitiesController

Inherits:
BaseController show all
Defined in:
app/controllers/stay/admin/cities_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#load_stores, #set_currency, #set_current_store, #stores_scope

Methods included from ControllerHelpers::Store

#current_store, #ensure_current_store, #store_locale

Methods included from ControllerHelpers::Currency

#currency_param, #current_currency, #supported_currencies, #supported_currencies_for_all_stores, #supported_currency?

Methods inherited from Stay::ApplicationController

#after_sign_in_path_for, #current_store

Methods included from LocaleHelper

#all_locales_options, #available_locales, #available_locales_options, #config_locale?, #current_locale, #find_with_fallback_default_locale, #locale_full_name, #locale_param, #locale_presentation, #params_locale?, #should_render_locale_dropdown?, #supported_locale?, #supported_locales, #supported_locales_for_all_stores, #supported_locales_options, #user_locale?

Methods included from CurrencyHelper

#currency_options, #currency_presentation, #currency_symbol, #should_render_currency_dropdown?, #supported_currency_options

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
27
# File 'app/controllers/stay/admin/cities_controller.rb', line 19

def create
  @city = @state.cities.new(city_params)
  if @city.save
    redirect_to admin_state_cities_path(@state), notice: 'City was successfully created.'
  else
    flash.now[:alert] = @city.errors.full_messages.join(', ')
    render :new
  end
end

#destroyObject



41
42
43
44
45
46
47
48
49
# File 'app/controllers/stay/admin/cities_controller.rb', line 41

def destroy
 if @city.destroy
    flash[:alert] = "City was successfully deleted."
    redirect_to admin_state_cities_path(@state)
  else
    flash[:alert] = @city.errors.full_messages.join(', ')
    redirect_to admin_state_cities_path(@state)
  end
end

#editObject



29
30
# File 'app/controllers/stay/admin/cities_controller.rb', line 29

def edit
end

#indexObject



6
7
8
9
10
11
12
13
# File 'app/controllers/stay/admin/cities_controller.rb', line 6

def index
  @cities = @state.cities
  respond_to do |format|
  format.html
  format.json { render json: @cities }
end

end

#newObject



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

def new
  @city = @state.cities.new
end

#updateObject



32
33
34
35
36
37
38
39
# File 'app/controllers/stay/admin/cities_controller.rb', line 32

def update
  if @city.update(city_params)
    redirect_to admin_state_cities_path(@state), notice: 'City was successfully updated.'
  else
    flash.now[:alert] = @city.errors.full_messages.join(', ')
    render :edit
  end
end