Class: IshLibEngine::Manager::CitiesController

Inherits:
Manager::ManagerController
  • Object
show all
Defined in:
app/controllers/ish_lib_engine/manager/cities_controller.rb

Instance Method Summary collapse

Instance Method Details

#change_profile_picObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'app/controllers/ish_lib_engine/manager/cities_controller.rb', line 61

def change_profile_pic
  authorize! :change_profile_pic, ManagerCity.new

  @city = City.find params[:id]
  
  @photo = Photo.new params[:photo]
  @photo.user = @current_user
  flag = @photo.save
  @city.profile_photo = @photo
  flagg = @city.save
  if flag && flagg
    flash[:notice] = 'Success'
  else
    flash[:error] = "No Luck. #{@photo.errors.inspect} #{@city.errors.inspect}"
    # puts! @photo.errors.inspect
    # puts! @city.errors.inspect
  end

  redirect_to manager_cities_path
end

#createObject



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/ish_lib_engine/manager/cities_controller.rb', line 24

def create
  authorize! :create, ManagerCity.new
  @city = City.new params[:city].permit( :n_features, :n_newsitems, :x, :y, :is_feature, :cityname,
                                         :name_pt, :name_en, :name_ru, :name )
  
  if @city.save
    flash[:notice] = 'Success'
    redirect_to manager_cities_path
  else
    flash[:error] = 'No Luck'
    render :action => :new
  end
end

#editObject



38
39
40
# File 'app/controllers/ish_lib_engine/manager/cities_controller.rb', line 38

def edit
  authorize! :edit, @city
end

#indexObject



7
8
9
10
11
12
# File 'app/controllers/ish_lib_engine/manager/cities_controller.rb', line 7

def index
  authorize! :index, ManagerCity.new
  @cities = City.all
  @city = City.new
  @photo = Photo.new
end

#newObject



18
19
20
21
22
# File 'app/controllers/ish_lib_engine/manager/cities_controller.rb', line 18

def new
  authorize! :new, ManagerCity.new
  @city = City.new
  @photo = Photo.new
end

#showObject



14
15
16
# File 'app/controllers/ish_lib_engine/manager/cities_controller.rb', line 14

def show
  authorize! :show, @city
end

#updateObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/controllers/ish_lib_engine/manager/cities_controller.rb', line 42

def update
  authorize! :update, ManagerCity.new

  @city = City.find( params[:id] )

  @city.update_attributes params[:city]    
  
  if @city.save
    flash[:notice] = 'Success'
    redirect_to edit_manager_city_path @city.id
  else
    flash[:error] = 'No Luck. ' + @city.errors.inspect
    @newsitems = @city.newsitems.all.page( params[:newsitems_page] )
    @features = @city.features.all.page( params[:features_page] )
    @photo = Photo.new
    render :action => :edit
  end
end