mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Removing some unuseful begin/end and refactor prompt_option_tag a bit
[#5469 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
This commit is contained in:
parent
27edd3f8bc
commit
0aefbe52a0
1 changed files with 11 additions and 16 deletions
|
@ -751,10 +751,8 @@ module ActionView
|
||||||
# => [nil, "Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
# => [nil, "Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||||
# "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
# "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
||||||
def translated_month_names
|
def translated_month_names
|
||||||
begin
|
key = @options[:use_short_month] ? :'date.abbr_month_names' : :'date.month_names'
|
||||||
key = @options[:use_short_month] ? :'date.abbr_month_names' : :'date.month_names'
|
I18n.translate(key, :locale => @options[:locale])
|
||||||
I18n.translate(key, :locale => @options[:locale])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Lookup month name for number
|
# Lookup month name for number
|
||||||
|
@ -781,9 +779,7 @@ module ActionView
|
||||||
memoize :date_order
|
memoize :date_order
|
||||||
|
|
||||||
def translated_date_order
|
def translated_date_order
|
||||||
begin
|
I18n.translate(:'date.order', :locale => @options[:locale]) || []
|
||||||
I18n.translate(:'date.order', :locale => @options[:locale]) || []
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Build full select tag from date type and options
|
# Build full select tag from date type and options
|
||||||
|
@ -837,15 +833,14 @@ module ActionView
|
||||||
# prompt_option_tag(:month, :prompt => 'Select month')
|
# prompt_option_tag(:month, :prompt => 'Select month')
|
||||||
# => "<option value="">Select month</option>"
|
# => "<option value="">Select month</option>"
|
||||||
def prompt_option_tag(type, options)
|
def prompt_option_tag(type, options)
|
||||||
default_options = {:year => false, :month => false, :day => false, :hour => false, :minute => false, :second => false}
|
prompt = case options
|
||||||
|
when Hash
|
||||||
case options
|
default_options = {:year => false, :month => false, :day => false, :hour => false, :minute => false, :second => false}
|
||||||
when Hash
|
default_options.merge!(options)[type.to_sym]
|
||||||
prompt = default_options.merge(options)[type.to_sym]
|
when String
|
||||||
when String
|
options
|
||||||
prompt = options
|
else
|
||||||
else
|
I18n.translate(:"datetime.prompts.#{type}", :locale => @options[:locale])
|
||||||
prompt = I18n.translate(('datetime.prompts.' + type.to_s).to_sym, :locale => @options[:locale])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
prompt ? content_tag(:option, prompt, :value => '') : ''
|
prompt ? content_tag(:option, prompt, :value => '') : ''
|
||||||
|
|
Loading…
Reference in a new issue