I am trying to do a feed (kinda timeline following feed in a daily manner)
I have a table photos
where it stores photos uploaded by the user, a table follows
which stores the user that each user is following.
create_table "photos", force: :cascade do |t| ... t.integer "user_id" t.datetime "created_at" t.datetime "updated_at" ...create_table "follows", force: :cascade do |t| t.integer "followable_id", null: false t.string "followable_type", null: false t.integer "follower_id", null: false t.string "follower_type", null: false ... t.datetime "created_at" t.datetime "updated_at"end
Basically, I want to accomplish a feed that looks like this (easier drawn than explain)
- most recent appear at the top
- group all photos uploaded by the user we are "following" including my own in "a day"
- display today, yesterday, 2 days ago and so forth