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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:30:19+00:00 2026-05-14T22:30:19+00:00

Im learning rails and exploring a bit away from the book and creating a

  • 0

Im learning rails and exploring a bit away from the book and creating a simple application with added functionality as i increase my knowledge. Im writing a simple blog application and i have a field in the form called date added, i don’t want this to be a field i want it to get the date from the server and place it in to the database automatically. How would i go about doing this? I was thinking of a hidden field but then unsure on how to process the date and insert it to the hidden field. Is this the wrong way of going about things?

Thanks in Advance,

Dean

  • 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-14T22:30:19+00:00Added an answer on May 14, 2026 at 10:30 pm

    I would not use a hidden field, because even if it is hidden the user can manipulate this. I think the best way to solve this problem is, ignore the date in the form and add the date to you your model in the controller action right before saving the object:

    def SomeController
      #...
      def create
        @model = Model.new params[:model]
        @model.date_field_name = Time.now
        if @model.save
          # whatever should be done if validation passes or
          redirect_to @model
        else
          # whatever should be done if validation fails or
          render :new
        end
      end
      #...
    end
    

    But you don’t have to do any of this, because ruby on rails offers the two columns created_at and updated_at. created_at will be set when the object gets created and updated_at will be set every time when you update this object.

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

Sidebar

Related Questions

I'm currently learning rails by creating a simple project management app. I've gotten to
I'm learning Rails by writing simple TODO tasks aplication. Two models are: class List
I'm learning Rails, and got into a little problem. I'm writing dead simple app
I've created a simple application to assist me in learning Rails. Because I like
As part of learning ruby/rails, I'm trying to implement http://github.com/professionalnerd/simple-private-messages into my application from
This is a beginner's rails learning confusion. When I learn rails, from time to
I'm reading the book Learning Rails by O'Reilly and it recommends using the validate_existence_of
I'm working on learning ruby/rails at the moment - The book i'm reading has
While learning Rails I've created an application with a Domains controller nested below a
I'm just learning rails and I've run into a bit of a snag. Let

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.