For example, I will select a time and if I click "search", it will list all booking in that time.
on my database: booking_time: '2000-01-01 8:00:00'
This is the time want to search: '2000-01-01 8:00:00'
but the system output is: Booking time is available
why? i enter '2000-01-01 8:00:00' but it is existent in the database.. what is the problem?
new.html.rb
<%= form_for @search, html: {class: "pure-form"} do |s| %>
<%= s.time_select :search %>
<% end %>
search.rb
class Search < ActiveRecord::Base
def search_bookings
bookings = Booking.all
bookings = bookings.where(booking_time: search) if search.present?
bookings
end
end
show.html.erb
<% if @search.search_reservations.empty? %>
"Booking time is available."
<% else %>
"Booking time is already exist."
<% end %>
<% end %>
Aucun commentaire:
Enregistrer un commentaire