Search code examples
ruby-on-railsrubydatetimecontrollers

Date And Time Needed


Well, I want to display departure and arrival times(with dates) for my flights application.

I had created two fields 'departure' and 'arrival' with data-type datetime.

What methods can be used for these in the controller aand how can i show them in the index page.


Solution

  • suppose you have a arrival & departure in your flights table then

    In controller

    @flights = Flight.all
    

    In view

    <% for flight in @flights%>
      <%= flight.arrival %>
      <%= flight.departure %>
    <% end %>