A
Arun Kumar
Hi all,
How to add the condition for "order by birthdate desc" in the following
User have friends
User have profile
now = Date.today
end = now + 7.days
u= User.find(id)
@somevariable = u.friends.select{|f|
date = f.profile.birthdate if f.profile
selected = false
if date
if (now.month == date.month) && (date.day >= now.day && date.day <=
end_day.day )
selected =true
elsif (end.month == date.month) && (date.day <= end.day &&
end_day.month != today.month)
selected = true
else
selected=false
end
end
selected }
The above query is working fine but the order is displaying based on
alphabet,
But i need to show by soonest date (birthdate)
How to achieve this by using order by or any other method ?
Thanks in advance,
Jak
How to add the condition for "order by birthdate desc" in the following
User have friends
User have profile
now = Date.today
end = now + 7.days
u= User.find(id)
@somevariable = u.friends.select{|f|
date = f.profile.birthdate if f.profile
selected = false
if date
if (now.month == date.month) && (date.day >= now.day && date.day <=
end_day.day )
selected =true
elsif (end.month == date.month) && (date.day <= end.day &&
end_day.month != today.month)
selected = true
else
selected=false
end
end
selected }
The above query is working fine but the order is displaying based on
alphabet,
But i need to show by soonest date (birthdate)
How to achieve this by using order by or any other method ?
Thanks in advance,
Jak