i created a simple search input form for a Rails application, but i noticed that when i dont input anything it returns a result of all my users, but i dont want it to work when no value is placed
My form
<h6>Search for Friends</h6>
<form action ="users/search" method="post">
<input name = "key" type="input" />
<input value="Search" type="submit"/>
</form>
Controller method
def search
@users = User.find(:all,:order => 'username', :conditions => ["username LIKE ?", "%#{params[:key]}%"])
end
Try the new Arel writing or check if the key was assigned.
or