Class: IshLibManager::CitiesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- IshLibManager::CitiesController
- Defined in:
- app/controllers/ish_lib_manager/cities_controller.rb
Instance Method Summary collapse
- #change_profile_pic ⇒ Object
- #create ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#change_profile_pic ⇒ Object
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 :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 |
#create ⇒ Object
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 :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 |
#edit ⇒ Object
40 41 42 |
# File 'app/controllers/ish_lib_manager/cities_controller.rb', line 40 def edit :edit, @city end |
#index ⇒ Object
8 9 10 11 12 13 14 |
# File 'app/controllers/ish_lib_manager/cities_controller.rb', line 8 def index :index, ManagerCity.new @cities = City.all.to_a @city = City.new @photo = Photo.new end |
#new ⇒ Object
20 21 22 23 24 |
# File 'app/controllers/ish_lib_manager/cities_controller.rb', line 20 def new :new, ManagerCity.new @city = City.new @photo = Photo.new end |
#show ⇒ Object
16 17 18 |
# File 'app/controllers/ish_lib_manager/cities_controller.rb', line 16 def show :show, @city end |
#update ⇒ Object
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 :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 |