0

I am using time_select in a rails view, it looks something like this:

<div class="field">
    <%= f.label :StartTime, "Start Time" %><br />
    <%= f.time_select :StartTime %>
</div>

I want to set the default time to 09:00 (AM), how would I do that?

Sergio Tulentsev
  • 226,338
  • 43
  • 373
  • 367
Art F
  • 3,992
  • 10
  • 49
  • 81

1 Answers1

5

What about setting corresponding model property?

def new
  @session = Session.new
  @session.StartTime = Time.now.beginning_of_day + 9.hours
end

Note that in Ruby it's against widely accepted conventions to name methods in PascalCase. StartTime should become start_time.

(I took the liberty of naming the model Session, since you didn't specify any name).

Sergio Tulentsev
  • 226,338
  • 43
  • 373
  • 367