Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9068313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:09:43+00:00 2026-06-16T17:09:43+00:00

Developing a web application that will act similar to a daily journal. The user

  • 0

Developing a web application that will act similar to a daily journal. The user can maintain several different lists of data for a given date. For the sake of discussion say we have two models, Notes and Tasks.

I would like to present a view to the user of dates they can navigate through showing the data for each date. Maybe in a strictly list view such as:

Jan 1
======
Tasks: 1 - First task is here
       2 - Second task is here

Notes: 1 - First note is here


Jan 4
=====
Tasks:  No tasks

Notes:  1 - A note is here.
        2 - Another note...

<< Older Entries        Newer Entries >>

Or maybe presented as a calendar having dates which have corresponding data marked or highlighted somehow.

I started down the path building out my models as just Notes and Tasks, each having a journal_date on them. This works fine when navigating each model index independently. Such as myapp.com/notes/ or myapp.com/tasks/ But I’m not sure how difficult it will be to consolidate each list into one view grouped by date.

I also considered having a model called JournalEntry, which has a journal_date, and has_many notes and has_many tasks. Then the notes and tasks wouldn’t have a date, but they would each belong to a journal_entry which has a date. I think that would simplify things a bit. But I’ve read a few blog posts which say stay away from nested resources if possible. So something like: myapp.com/nick/journal_entries/2012-dec-23/tasks/ they say to stay away from because of the code becoming complex.

So I’m wondering how some more experienced rails developers would approach this problem? Which approach would you use, or would you handle it completely differently?

Nick

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:09:44+00:00Added an answer on June 16, 2026 at 5:09 pm

    One way to do it without changing your model setup would be to group each model scope on the journal_date column and then loop through a unique list of the keys from the group hash, like this:

    # Controller
    since_date = DateTime.now - 30.days
    @tasks = Task.where("journal_date > ?", since_date).group_by(:journal_date)
    @notes = Note.where("journal_date > ?", since_date).group_by(:journal_date)
    @date_entries = (@tasks.keys + @notes.keys).uniq
    
    # View
    <% @date_entries.each do |date_entry| %>
      <h1><%= date_entry.to_s %></h1>
      <h2>Tasks</h2>
      <% if @tasks[date_entry].any? %>
        <% @tasks[date_entry].each do |task| %>
          <p><%= task.title %></p>
        <% end %>
      <% else %>
        <p>No Tasks</p>
      <% end %>
    
      <h2>Notes</h2>
      <% if @notes[date_entry].any? %>
        <% @notes[date_entry].each do |note| %>
          <p><%= note.title %></p>
        <% end %>
      <% else %>
        <p>No Notes</p>
      <% end %>
    <% end %>
    

    The since_date part is of course just an example of putting some conditions for the retrieved records.

    And the group_by(:journal_date) will only work if the column is of the type Date and not a DateTime. If it is a DateTime then you can solve it like this instead:

    group_by { |journal_date| journal_date.to_date }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a web application that will interact with google APIs. Since the only
I am designing/developing a web application that will ultimately deploy as a WAR to
I'm developing a Web application that will let users upload images. My concern is
I am developing a single web application that will dynamically change its content depending
I'm developing a web application that will need to be localized to English and
We have plans of developing a web application that will have to communicate with
Greetings friends, I am developing a web application that will allow the customer to
We are developing a search engine web application that will enable users to search
Background: We are developing a web application that includes charts. Currently one can left-click
I'm developing web-application (and also native iOS app) that uses images from different websites.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.