Quick question. If I have a Model, say Charities, that has a start_date and an end_date attribute, how can I set that to be the current_charity from a method in the Controller?
I know I’ll have to do some kind of Charities.find(params[:something]), and will just have to set that current_charity equal to one that’s start_date is >= the current date, and who’s end_date is <= the current date (there is only one “current” one at a time). I’ve usually just found a Model by the params[:id], so this is new to me.
Thank you!
Add a scope method in your model:
Then in your controller: