Class: IshLibManager::CitiesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ish_lib_manager/cities_controller.rb

Instance Method Summary collapse

Instance Method Details

#change_profile_picObject



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

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



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/ish_lib_manager/cities_controller.rb', line 26

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



40
41
42
# File 'app/controllers/ish_lib_manager/cities_controller.rb', line 40

def edit
  authorize! :edit, @city
end

#indexObject



8
9
10
11
12
13
14
# File 'app/controllers/ish_lib_manager/cities_controller.rb', line 8

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

#newObject



20
21
22
23
24
# File 'app/controllers/ish_lib_manager/cities_controller.rb', line 20

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

#showObject



16
17
18
# File 'app/controllers/ish_lib_manager/cities_controller.rb', line 16

def show
  authorize! :show, @city
end

#updateObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/controllers/ish_lib_manager/cities_controller.rb', line 44

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