lib/app/models/cli.rb
#USER STORY 1) ENTER A NEW TRIP
#allows user to enter attributes of a trip through prompts and addes stops through helper methods
USER STORY 1) ENTER A NEW TRIP
allows user to enter attributes of a trip through prompts and addes stops through helper methods
USER STORY 1 ) ENTER A NEW TRIP allows user to enter attributes of a trip through prompts and addes stops through helper methods
def enter_new_trip(user)
    puts "\nEnter a new Trip"
    puts "What is the name of your trip?"
        trip_name = gets.chomp
    puts "\nWhat was your method of transportation?"
        transportation = gets.chomp
    date_found = false
    while not date_found
        puts "What was your start date? (YYYY/MM/DD)"
        date = gets.chomp
        start_date = Date.parse(date)
        puts "\nThe start date is #{start_date}. Is this correct? (Y/N)"
        user_response = gets.chomp
            if user_response.downcase == 'y'
                date_found = true
            end
        end
    puts "\nHow many days did you spend on this trip?"
        duration = gets.chomp.to_i
        user_end_date = start_date + duration
    trip = Trip.create(
        user_id: user.id, 
        name: trip_name, 
        transportation: transportation,
        start_date: start_date,
        end_date: user_end_date
        )
    create_locations(trip)
end
def enter_new_trip ( user ) puts "\nEnter a new Trip" puts "What is the name of your trip?" trip_name = gets . chomp puts "\nWhat was your method of transportation?" transportation = gets . chomp date_found = false while not date_found puts "What was your start date? (YYYY/MM/DD)" date = gets . chomp start_date = Date . parse ( date ) puts "\nThe start date is #{start_date}. Is this correct? (Y/N)" user_response = gets . chomp if user_response . downcase == 'y' date_found = true end end puts "\nHow many days did you spend on this trip?" duration = gets . chomp . to_i user_end_date = start_date + duration trip = Trip . create ( user_id : user . id , name : trip_name , transportation : transportation , start_date : start_date , end_date : user_end_date ) create_locations ( trip ) end
USER STORY 1) ENTER A NEW TRIP
allows user to enter attributes of a trip through prompts and addes stops through helper methods
USER STORY 1 ) ENTER A NEW TRIP allows user to enter attributes of a trip through prompts and addes stops through helper methods
user