I have an event with many guests for that event. A guest must search themselves using their ID to RSVP but I cannot get the search to return that guests info (show/edit page).
The search tag:
<div>
<h3>Enter your ID here:</h3>
<%= form_for "", url: event_guest_path(@event,@guest), role: 'search', method: :get do %>
<%= text_field_tag :search, @search_term, placeholder: "Search.." %>
<% end %>
</div>
GuestController:
def show
if params[:search]
@search_term = params[:search]
@guest = @event.guests.search_by(@search_term)
end
end
Guest.rb:
def self.search_by(search_term)
where("(id) LIKE :search_term", search_term: "%#{search_term}%")
end
At the moment it keeps taking me to the index page but I want it to return the guest path where they can make their RSVP.