I have these two methods that I would like to combine into one. But for the life of me I can’t see how. NOOB big time. any help appreciated.
def is_active_no_category
'active' if params[:category].blank?
end
def is_active(category)
'active' if params[:category] == category.name.parameterize
end
With the below function passing a
categoryas an argument is optional. If you do not pass an argument it will work like youris_active_no_categorymethod. If you do pass an argument. It will work like youris_activemethod.You may be able to make the
ifstatement more compact, but you haven’t stated the exact requirements for your function, so I gave you the most complete solution.