time_select tag problem with globalite plugin

By , May 20, 2009 1:30 am

Recently  I used time_select tag in my project and  I got strange error.

Error is: “Can’t convert nil into string”. After lots of hard work I found that this problem was raised from globalite plugin.

To fix  this issue, I apply below code  in plugins/globalite/lib/rails/localized_action_view.rb (change in select_month method)

def select_month(date, options = {}, html_options = {})
if options[:locale]
@original_locale = Locale.code
Locale.code = options[:locale]
end
val = date ? (date.kind_of?(Fixnum) ? date : date.month) : "
if options[:use_hidden]
hidden_html(options[:field_name] || 'month', val, options)
else
month_options = []
monthnames = :date_helper_month_names.l
abbr_monthnames = :date_helper_abbr_month_names.l
month_names = options[:use_month_names] || (options[:use_short_month] ? abbr_monthnames : monthnames)
month_names.unshift(nil) if month_names.size < 13
1.upto(12) do |month_number|
month_name = if options[:use_month_numbers]
month_number
elsif options[:add_month_numbers]
month_number.to_s + ' - ' + month_names[month_number]
else
month_names[month_number]
end

month_options << ((val == month_number) ?
%(<option value="#{month_number}" selected="selected">#{month_name}</option>\n) :
%(<option value="#{month_number}">#{month_name}</option>\n)
)
end
@selector = select_html(options[:field_name] || 'month', month_options, options)
Locale.code = @original_locale if options[:locale]
return @selector
end
#  Locale.code = @original_locale if options[:locale]
#  return @selector
end

Another solution is:  Comment the date module code in

plugins/globalite/lib/rails/localized_action_view.rb

Panorama Theme by Themocracy