Jigar Gosar
2006-Feb-05 18:36 UTC
[Rails] How can i specify default time to datetime_select tag
I want to specify a different default time to datetime_select tag how can i do that. also i was looking at rails helper code ----------------------------------------------------------------------- module ActionView module Helpers module DateHelper def to_datetime_select_tag(options = {}) defaults = { :discard_type => true } options = defaults.merge(options) options_with_prefix = Proc.new { |position| options.merge(:prefix => "#{@object_name}[#{@method_name}(#{position}i)]") } datetime = options[:include_blank] ? (value || nil) : (value || Time.now) datetime_select = select_year(datetime, options_with_prefix.call(1)) datetime_select << select_month(datetime, options_with_prefix.call(2)) unless options[:discard_month] datetime_select << select_day(datetime, options_with_prefix.call(3)) unless options[:discard_day] || options[:discard_month] datetime_select << '' — '' + select_hour(datetime, options_with_prefix.call(4)) unless options[:discard_hour] datetime_select << '' : '' + select_minute(datetime, options_with_prefix.call(5)) unless options[:discard_minute] || options[:discard_hour] datetime_select end ----------------------------------------------------------------------- i was wondering where did the variable value come from in follong line: datetime = options[:include_blank] ? (value || nil) : (value || Time.now) -- Posted via http://www.ruby-forum.com/.
Possibly Parallel Threads
- Overriding date_select in local project to use custom value rather than blank for starting option...
- In datetime_select, :order does not work, but it works for date_select Why
- datetime_select and discard
- datetime_select discard year bug?
- Problem with date_select after Rails 2.1 upgrade