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 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:
month = params[:selected_month] ? params[:selected_month] : Date.today.strftime("%B")
@posts = Post.by_month(month)
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")
by Date.today.strftime("%m")