File size: 1,445 Bytes
f5071ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
json.spots do
    json.set! @spot.id do
        json.extract! @spot, :id, :title, :description,:num_guests,:num_bedrooms,
                        :num_beds,:num_baths,:listing_type, :price, :location, 
                        :loc_detail,:lat, :lng,:host_id, :wifi, :washer, 
                        :tv, :elevator, :parking, :kitchen
            json.hostId @spot.host_id
            json.spotType @spot.listing_type                        
            json.photoUrls @spot.photos.map { |photo| url_for(photo) } 
    end
end

json.users do
    json.set! @spot.host.id do
         json.extract! @spot.host, :id, :username, :fname, :bio
         json.photoUrl url_for(@spot.host.photo) if @spot.host.photo.attached?
    end
end



# json.extract! @spot, :id, :title, :description,:num_guests,:num_bedrooms,
#                         :num_beds,:num_baths,:listing_type, :price, :location, 
#                         :loc_detail,:lat, :lng,:host_id, :wifi, :washer, 
#                         :tv, :elevator, :parking, :kitchen
#             json.hostId @spot.host_id
#             json.spotType @spot.listing_type                        
#             json.photoUrls @spot.photos.map { |photo| url_for(photo) }                     




# json.users do
#     json.set! @spot.host.id do
#         json.extract! @spot.host, :id, :username, :fname, :bio
#         json.photoUrl url_for(@spot.host.photo) if @spot.host.photo.attached?
#     end
# end