Class: PhcdevworksRealEstate::Property::ListingsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/phcdevworks_real_estate/property/listings_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /property/listings



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/phcdevworks_real_estate/property/listings_controller.rb', line 32

def create
  @property_listing = Property::Listing.new(property_listing_params)
  @property_listing.user_id = current_user.id
  @property_listing.org_id = current_user.org_id
  respond_to do |format|
    if @property_listing.save
      format.html { redirect_to property_listings_path, :flash => { :success => 'Property Listing has been Added.' }}
      format.json { render :show, status: :created, location: @property_listing }
    else
      format.html { render :new }
      format.json { render json: @property_listing.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /property/listings/1



61
62
63
64
65
66
67
# File 'app/controllers/phcdevworks_real_estate/property/listings_controller.rb', line 61

def destroy
  @property_listing.destroy
  respond_to do |format|
    format.html { redirect_to property_listings_path, :flash => { :error => 'Property Listing has been Removed.' }}
    format.json { head :no_content }
  end
end

#editObject

GET /property/listings/1/edit



28
29
# File 'app/controllers/phcdevworks_real_estate/property/listings_controller.rb', line 28

def edit
end

#indexObject

GET /property/listings



13
14
15
# File 'app/controllers/phcdevworks_real_estate/property/listings_controller.rb', line 13

def index
  @property_listings = Property::Listing.all
end

#newObject

GET /property/listings/new



23
24
25
# File 'app/controllers/phcdevworks_real_estate/property/listings_controller.rb', line 23

def new
  @property_listing = Property::Listing.new
end

#showObject

GET /property/listings/1



18
19
20
# File 'app/controllers/phcdevworks_real_estate/property/listings_controller.rb', line 18

def show
  @property_listing = Property::Listing.friendly.find(params[:id])
end

#updateObject

PATCH/PUT /property/listings/1



48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/phcdevworks_real_estate/property/listings_controller.rb', line 48

def update
  respond_to do |format|
    if @property_listing.update(property_listing_params)
      format.html { redirect_to property_listings_path, :flash => { :notice => 'Property Listing has been Updated.' }}
      format.json { render :show, status: :ok, location: @property_listing }
    else
      format.html { render :edit }
      format.json { render json: @property_listing.errors, status: :unprocessable_entity }
    end
  end
end