Hey everyone I have a basic search function here that allows me to search for users by name, I also want to add an email attribute but I’m not sure how. I think this should be a relatively easy fix. Heres all the relevant code:
Search form:
<%= text_field_tag :search, params[:search], :class => 'search_field' %>
<%= submit_tag "Search", :name => nil %>
Controller:
@usersearch = User.search(params[:search])
User model:
def self.search(search)
if search
where('name LIKE ?', "%#{search}%")
else
all
end
end
Thanks in advance!
Just add OR statement with email: