Write Ruby Hash with duplicate values without repeating value -
i have following code in rails controller:
@users = user.where(["first_name = :first_name or last_name = :last_name or company = :company", { first_name: term, last_name: term, company: term }])
term term = params[:search]
i don't i'm repeating term
{ first_name: term, last_name: term, company: term }
is there dryer way accomplish this?
thank you!
you can this:
@users = user.where("first_name = :term or last_name = :term or company = :term", term: term)
Comments
Post a Comment