Closed adamhoff closed 7 years ago
It sounds like your days are being sorted by updated_at
. If display order is important (and I'm guessing it is for a calendar app) you'll need to enforce that order yourself.
One option is to sort the list as you're displaying it in app/views/months/show
line 3
<% @month.days.sort_by {|day| day.date}.each do |day| %>
Another option is to have the database do the sorting for you by using the ActiveRecord method .order()
in your controller action instead of .all()
. More info here: http://guides.rubyonrails.org/active_record_querying.html#ordering
@adamhoff Did this solve your issue?
Yes it did thank you!
How do I make it so that whenever i update one of the days through edit, the day keeps its same position instead of appending to the end of the month? https://github.com/adamhoff/calendar