Wecome to CozyBnB! This is a clone of the website AirBnB that provides the user many features from the original.
Check it out here => https://cozybnb.herokuapp.com/#/ #
Starting with the backend, I used Ruby on Rails along with PostGresQL DB, jBuilder DSL to sculpt and limit the json sent up to the frontend. I used React and Redux to deliver the user interface and manage state respectively on the frontend. Mapbox API was used for marking locations. #
A lot of problems I encountered occured were while creating the search bar and search function. None of the listings were displaying when searching for a particular location. I ended up manipulating my listings controller to add conditionals to check whether searchParams present, created a method to query using searchParams insteade of the ID of homes. I set my state to include the key of city and value of searchParams and called the route for my Homes Index.
Searching for a listing by its city was complicated and was done by adding data to the backend containing the search params. Searching a city in the search bar would fetch the listings in that city (searchParams)
def index
if !params[:searchParams]
# debugger
@homes = Home.all
elsif params[:searchParams][:city]
# debugger
@homes = Home.where(city: params[:searchParams][:city])
end
render :index
end
#