Ernesto Gutierrez


1,400 Experience
6 Lessons Completed
1 Question Solved


Nested forms make sense to me in theory but in practice I can't seem to see the implementation of it in an attendance tracker.
Here's the repo:

Here's a quick view of what I'm shooting for:

What I'm trying to do is setup an attendance app similar to
I'm not trying to clone it 1for1 but I'm trying to match the abilty to select multiple students from a list / table and mark them as [present, absent, excused, other]. Once they are marked with an attendance only those present are visible to take the next action mark hours of participation.

The part I've been stuck on is the select multiple and assign an attendance type. If you read from the top post I've been looking into this but can't seem to get it right.

The last 2 suggestions had me to the following to the AttendancesController

def mark_student #this is the most recnet attempt

    @students = Array(params[:student_ids].split(",")
    @students.each do |s|
     student = Student.find(s)!

    # @students = params[:student_ids].split(",") #this was the second suggestion
    # @students.each do |s|
    #  student = Student.find(s)
    #  student.attendances.create
    # end

    redirect_to attendances_url


Redirected this question to the Slack Group got this response:

class AttendancesController < ApplicationController
  def mark
    @students = Student.where(id: params[:student_ids])

    ActiveRecord::Base.transaction do
      @students.each do |student|
        attendence = student.attendences.create(date: attendence_params[:date])


  def attendence_params
class AttendancesController < ApplicationController
  def mark
    @attendance_day = AttendanceDay.find(params[:attendance_day_id])
    @attendance_day.student_ids = params[:student_ids]

I'm a visual learner so having this to refer back to actually helped me understand how I can take an array like student_ids collected from a form and have the controller irreate on them to create in my case an attendance record. Currently there's a has_many / belongs_to association between the students & attendances model.

With the reponses I may end up uisng a joiner model to bridge Students & Attendnances with a has_many, through this way the end result would be:

class Student < ApplicationRecord
  has_many :attendances
    has_many :records, :through => :attendances
class Attendance < ApplicationRecord
  belongs_to :record
    belongs_to :student
class Record < ApplicationRecord
  has_many :attendances
    has_many :students, :through => :attendances

I've been racking my brain and just need to ask for help on the creating this function in my app.

Scope: simple app for non-profit for tracking student attendance
What I've done:

  • created the app
  • shared the app with the end people
  • received positive feedback

What's missing for them is the ability to record attenance for multiple students at once. Without this they can not see the benefit of using this and I'm stuck maitaining an google sheet spreadsheet for them.

This (from what I've read) should be done in two steps:
Step 1 - record the date/time of the attendance for multiple students
Step 2 - record the hours / record you want to track for those that are present

  • a dozen more

Form 1 - mark students attendnace
for now I'm just sticking with checkboxes but i'm sure I'll move to something more dynamic with java script or something else but for now let's keep it simple.

From 2 - mark hours / record for present students
I'm getting fancy I know but the idea would be select all / select one / select a few and record hours for each student.


class Student <ActiveRecord::Base
    has_many :attendances, dependent: :destroy
    validates :first_name, :last_name, :school_grade, :team_name, :presence => true
class Attendance < ActiveRecord::Base
    belongs_to :student
    has_many :attendance_records
class Records <ActiveRecord::Base
    belongs_to :attendance
    belongs_to :student through: :attendance

I work on this in the evenings after my kids go to sleep so any help will significantly help reduce my :coffee: intake to normal healthy levels.

Posted in School System

Consigo pero me falta practica con la escritura.

What are you trying to do with your app?

Posted in What is your dream app?

Currently working on:

  • attendnace app inspired by classdojo but for wife's non-profit
  • angie's list type site for renters to check out what previous renters thought about the rental
  • parent app lunch menu maker for picky eaters based on favorite foods

DreamApp - see above

Posted in School System

Hi Jorge, were you able to check out that blog post to help you get started?

Posted in School System

Working on something similar and I was stuck on this too but i'm only ahead of you by a few steps. Do you have any of your models set up yet? How far along are you?

I used this post to help me naviagte the attendance recording but I'm stuck on the ability to post attendnace for multiple studetns at once.

Check it out and let chat me up on the slack group.

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

© 2024 GoRails, LLC. All rights reserved.