Class: PlacesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- PlacesController
- Defined in:
- app/controllers/places_controller.rb
Overview
The places controller.
Instance Method Summary (collapse)
-
- (Object) create
POST /places POST /places.json.
-
- (Object) destroy
DELETE /places/1 DELETE /places/1.json.
-
- (Object) edit
GET /places/1/edit.
-
- (Object) index
GET /places GET /places.json.
-
- (Object) new
GET /places/new.
-
- (Object) show
GET /places/1 GET /places/1.json.
-
- (Object) update
PATCH/PUT /places/1 PATCH/PUT /places/1.json.
Instance Method Details
- (Object) create
POST /places POST /places.json
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/controllers/places_controller.rb', line 40 def create @place = Place.new(place_params) @place.customer = current_customer respond_to do |format| if @place.save format.html { redirect_to @place, notice: 'Place was successfully created.' } format.json { render action: 'show', status: :created, location: @place } else format.html { render action: 'new' } format.json { render json: @place.errors, status: :unprocessable_entity } end end end |
- (Object) destroy
DELETE /places/1 DELETE /places/1.json
75 76 77 78 79 80 81 |
# File 'app/controllers/places_controller.rb', line 75 def destroy @place.destroy respond_to do |format| format.html { redirect_to places_url } format.json { head :no_content } end end |
- (Object) edit
GET /places/1/edit
32 33 34 35 36 |
# File 'app/controllers/places_controller.rb', line 32 def edit if @place.latitude.nil? or @place.longitude.nil? set_default_location end end |
- (Object) index
GET /places GET /places.json
9 10 11 12 13 14 15 |
# File 'app/controllers/places_controller.rb', line 9 def index if current_customer.role == 'admin' @places = Place.all else @places = Place.my(current_customer) end end |
- (Object) new
GET /places/new
24 25 26 27 28 29 |
# File 'app/controllers/places_controller.rb', line 24 def new @place = Place.new # default location: Mopius HQ set_default_location end |
- (Object) show
GET /places/1 GET /places/1.json
19 20 21 |
# File 'app/controllers/places_controller.rb', line 19 def show @tags = @place. end |
- (Object) update
PATCH/PUT /places/1 PATCH/PUT /places/1.json
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/controllers/places_controller.rb', line 57 def update respond_to do |format| if @place.update(place_params) format.html { redirect_to @place, notice: 'Place was successfully updated.' } format.json { head :no_content } else if @place.latitude.nil? or @place.longitude.nil? set_default_location end format.html { render action: 'edit' } format.json { render json: @place.errors, status: :unprocessable_entity } end end end |