Skip to main content

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

Rails • Asked by Neil Patel

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'

its ok

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


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.