Ask A Question

Notifications

You’re not receiving notifications from this thread.

How do I display several posts in related "weeks"

Highzen berg asked in General

Hello everyone,,
I would like to structure my blog so that I can assign posts I have created with Trix and Shrine to weeks.
I want to have 12 teaserboxes on my index page which can then be clicked and if I click on week 1, for example, only the posts that are assigned to week 1 are displayed.
What's the smartest way to go? Should I make an extra week model? And can I somehow make a sort of assignment while creating the post that this post is a post for week 1? Are there any instructions or tips on how to do this? I'm totally overwhelmed with it right now. Currently all my posts are listed under /posts.

Reply

Depends on how many weeks you want to do, but I would add an extra week model as this allows you to grow the number of weeks without having to add more columns to your posts.

Then you can just pass a param to the posts index to specify the week that you want to display.

Alternative: You can add a 'week' column that is an integer and just put the week number in there, eg 1,2,3,4,5,6.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 84,256+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.