I have this code in my controller filter by month :
@posts = Post.by_month(params[:selected_month])
now I need to set current month as default value in case of nil ????
I have this code in my controller filter by month :
@posts = Post.by_month(params[:selected_month])
now I need to set current month as default value in case of nil ????
Copyright © 2021 Jogjafile Inc.
I guess you already implemented that method at your Model.
You can get the name of the current month with:
Date.today.strftime("%B")
So at your code:
This should be work if your method by_month search records by month name
If your method search by month number then change
Date.today.strftime("%B")
byDate.today.strftime("%m")