Class: IshManager::CitiesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- IshManager::CitiesController
- Defined in:
- app/controllers/ish_manager/cities_controller.rb
Instance Method Summary collapse
- #change_profile_pic ⇒ Object
- #create ⇒ Object
- #delete ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#change_profile_pic ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/controllers/ish_manager/cities_controller.rb', line 69 def change_profile_pic :update, City @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[:alert] = "No Luck. #{@photo.errors.} #{@city.errors.}" end redirect_to cities_path end |
#create ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/ish_manager/cities_controller.rb', line 31 def create @city = City.new params[:city].permit! :create, @city if @city.save flash[:notice] = 'Success' redirect_to cities_path else flash[:alert] = 'No Luck' render :action => :new end end |
#delete ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'app/controllers/ish_manager/cities_controller.rb', line 85 def delete c = City.find params[:id] if c.delete render else flash[:error] = c.errors. end end |
#edit ⇒ Object
44 45 46 |
# File 'app/controllers/ish_manager/cities_controller.rb', line 44 def edit :edit, @city end |
#index ⇒ Object
5 6 7 8 9 10 |
# File 'app/controllers/ish_manager/cities_controller.rb', line 5 def index :index, City @cities = City.unscoped @city = City.new @photo = Photo.new end |
#new ⇒ Object
24 25 26 27 28 29 |
# File 'app/controllers/ish_manager/cities_controller.rb', line 24 def new @city = City.new :new, City @photo = Photo.new end |
#show ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/ish_manager/cities_controller.rb', line 12 def show :show, @city @videos = @city.videos.page( params[:videos_page] ).per( Video::PER_PAGE ) @venues = @city.venues.page( params[:venues_page] ).per( Venue::PER_PAGE ) @galleries = @city.galleries.page( params[:galleries_page] ).per( Gallery::PER_PAGE ) @reports = @city.reports.page( params[:reports_page] ).per( Report::PER_PAGE ) @newsitems = @city.newsitems.page( params[:newsitems_page] ).per( Newsitem::PER_PAGE ) if params[:q] @venues = @venues.where({ :name => /#{params[:q]}/i }) end end |
#update ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/ish_manager/cities_controller.rb', line 48 def update @city = City.find( params[:id] ) :update, @city @city.update_attributes params[:city].permit! if params[:photo] photo = Photo.new :photo => params[:photo] @city.profile_photo = photo end if @city.save ::IshModels::CacheKey.one.update_attributes( :cities => Time.now, :feature_cities => Time.now ) flash[:notice] = 'Success' redirect_to city_path @city.id else flash[:alert] = '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 |