Ask A Question

Notifications

You’re not receiving notifications from this thread.

How do I add a default time of 6:45pm

Neil Patel asked in Rails

Hi

Following on from the my previous post

I want to add a new time column with the default of 6.46pm

I have tried this

class AddUsualStartTimeToAreas < ActiveRecord::Migration
def change
add_column :areas, :usual_start_time, :time, default: "18:45"
end
end

but it gives me a date?? which i don't want??

t.time    "usual_start_time",                         default: '2000-01-01 18:45:00'
Reply

its ok

in my area model i converted this to this usual_start_time.to_formatted_s(:time)
and is working

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,329+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    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.