Skip to main content
Ask A Question
Notifications
You’re not receiving notifications from this thread.
Subscribe

How do I display several posts in related "weeks"

General • Asked by Highzen berg

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.


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.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 30,005+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.