Phase 2 Sinatra Car Dealership Project
The goal of this project is to build Car Dealership that you can sell/buy your car .
In my project I have a toolbar that includes Main Menu , Inventory , Sell Your Car , Contact Us , About Us , Login , Sign Up, and Logout.

There are two models in app/models ; The user.rb and car.rb . Users have many cars , an username and password . Username must be uniqueness , username length must be between 5 to 30 and password has_secure_password . Car has content and belong to a user


I created two helper methods “current_user” and “logged_in?”. I use these helper methods to block content if a user is not logged in.

Users will see 2 different toolbar before logged_in and after logged_in . I used if — else statement in my code

For creating user you have to enter your username and password if user is valid it will redirect you to login page if username and password authenticate you will be redirected welcome page , else to sign up page. The form to login is loading via a GET request to /login and submit via a POST request to /login .

You have to fill form for creating your car , make , model, year, color, price and picture

You dont have to be logged in to see /carlist . But for click on it for edit or delete you have to logged_in if not you will redirect to login page . You will be able to delete or edit only if current user id is same with car user id .

After you fill the form you can see your car in inventory web page . @car.each do |car|lists all my cars in my database on carlist page

The controller action is clear the session hash, and redirect to the user to “/ ”. after user logged out

Thank you for reading about my project . I hope you enjoyed it