Hello,
I have a problem when with this tag in view:
<%= date_select :customdate, nil %>
In the controller there is:
d = Date.new
d = params[:customdate]
render_text “#{d.inspect}”
The problem is the :customdate doesnt get transformed
into Date, instead I get this:
{"(3i)"=>“29”, “(1i)”=>“2005”, “(2i)”=>“11”}
Any ideas how to solve it?
Best regards,
Tom
openbsdpl wrote:
Hello,
I have a problem when with this tag in view:
<%= date_select :customdate, nil %>
In the controller there is:
d = Date.new
d = params[:customdate]
render_text “#{d.inspect}”
The problem is the :customdate doesnt get transformed
into Date, instead I get this:
{"(3i)"=>“29”, “(1i)”=>“2005”, “(2i)”=>“11”}
Any ideas how to solve it?
Best regards,
Tom
Shouldn’t it be:
d = Date.new( params[:customdate] )
??
jonathan [email protected] napisaÅ?(a):
??
Nope. This throws an error:
NoMethodError in Forms#korpus_create_row
undefined method `-’ for {“(3i)”=>“30”, “(1i)”=>“2005”,
“(2i)”=>“11”}:HashWithIndifferentAccess
c:/ruby/lib/ruby/1.8/date.rb:297:in civil_to_jd' c:/ruby/lib/ruby/1.8/date.rb:568:in
valid_civil?’
c:/ruby/lib/ruby/1.8/date.rb:590:in new' #{RAILS_ROOT}/app/controllers/forms_controller.rb:279:in
korpus_create_row’
Tomasz B±k w:
Hello,
I have a problem when with this tag in view:
<%= date_select :customdate, nil %>
I have changed it into:
<%= date_select :row, :customdate %>
The problem is the :customdate doesnt get transformed
into Date, instead I get this:
{"(3i)"=>“29”, “(1i)”=>“2005”, “(2i)”=>“11”}
With this little function
def date_select_to_date(struct,name)
Date.new(struct["#{name}(1i)"].to_i,
struct["#{name}(2i)"].to_i,
struct["#{name}(3i)"].to_i)
end
I can get the date in the controller:
d = date_select_to_date(params[:row],'customdate ')
Tom.