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 7432841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:31:19+00:00 2026-05-29T09:31:19+00:00

I am trying to record a ‘time_in’, and ‘time_out’ record on a model called

  • 0

I am trying to record a ‘time_in’, and ‘time_out’ record on a model called ‘timeclock’. Here is what I am trying to do but can’t get to work!

  1. Check the last timeclock entry and see if it has both ‘time_in’ and ‘time_out’ records filled in. If so, then create a new record (like this?):

    form_for([@employee, @employee.timeclocks.build]) do |f|
    
      f.hidden_field :time_in, :value => @current_time 
    
      f.submit "Clock In"
    
    end
    
  2. If there’s already a timeclock record that is incomplete (has a ‘time_in’ record but not a ‘time_out’ record, render a form or update the last record.

I have been able to get the time records into the db, but never on the same data-record, like this: http://cl.ly/E0Rg (image)

Does that make sense? If you need some clarifying questions, don’t hesitate to ask! Thanks!

  • 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-05-29T09:31:20+00:00Added an answer on May 29, 2026 at 9:31 am

    with the code you present you always create new record as @employee.timeclocks.build is used to create record.

    If you want tu update a record you should fetch it first an then pass this record in the form_for method

    to fetch a record use @employee.timeclocks.find fappropriate where clause to get the record you want to update

    form_for([@employee, @timeclock]) do |f|
    
      f.hidden_field :time_in, :value => @current_time 
    
      f.submit "Clock In"
    
    end
    

    where you set @timeclock in you controller either in with a new record or with the record you want to update

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to delete an unmapped class/record via the NHibernate sql api. But can't seem
Im trying to record video using AVFoundation I can save images but not video.
I'm trying to record sound by creating an android application. here is the code:
I've tried to overcome this for a while. I'm trying to record sound, but
I am new to Nhibernate, I am trying to get record by ID and
Simply stated: I'm trying to record audio in a browser, and get that data
I'm trying to get a single record from my news feed. I pass it
I'm trying to get an MX record from an DNS server in C. My
I am trying to get the latest record inserted in a SQL table based
I am trying to get a total record count from the below Method using

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.