Undefined method `symbolize_keys! 'for 2: Fixnum

I am using ruby ​​1.9.2 and rails 3. When I start the application, I get the following error.

Error:

undefined method `symbolize_keys!' for 2:Fixnum line #606 raised: 

Code: line number 606

  <%= f.text_field :total_amount ,:label=>'Grand Total',:value =>number_with_precision(0,2),:readonly=>true %> 

Application Trace:

  actionpack (3.0.0) lib/action_view/helpers/number_helper.rb:238:in `number_with_precision' app/views/cashier/cashier/billing.rhtml:606:in `block (2 levels) in _app_views_cashier_cashier_billing_rhtml__3412897403160140582_59881040__1001215579093570677' actionpack (3.0.0) lib/action_view/helpers/capture_helper.rb:39:in `block in capture' actionpack (3.0.0) lib/action_view/helpers/capture_helper.rb:171:in `with_output_buffer' actionpack (3.0.0) lib/action_view/helpers/capture_helper.rb:39:in `capture' 

Please help me fix this error. Thanks in Advance !!!

+4
source share
2 answers

number_with_precision expects the second parameter to be the hash of the parameters

http://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_with_precision

In general, whenever you see the undefined method "symbolize_keys!", It means that you are passing another object or value where Ruby / Rails expects a Hash .

+10
source

putting this here for those who do not use Ruby, but sees this error when using an API that is encoded in Ruby, for example, Clock Hotel Software. I sent the JSON string as {"date":"2013-04-05","value":3} and received an error. it turned out that I had to place the array instead: [{"date":"2013-04-05","value":3}] fixed the error.

To deploy an aisrael answer, make sure the type of what you give the program on the other end is what is expected.

0
source

All Articles