Vijikumar M
Vijikumar M

Reputation: 3764

undefined method `symbolize_keys!' for 2:Fixnum

I am using ruby 1.9.2 and rails 3. I am getting the following error while running my application.

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 to correct this error. Thanks in Advance!!!

Upvotes: 4

Views: 5321

Answers (2)

jcomeau_ictx
jcomeau_ictx

Reputation: 38432

putting this here for those who don't use Ruby but see this error when using an API that is coded in Ruby such as Clock Hotel Software. I was posting a JSON string like {"date":"2013-04-05","value":3} to it and getting the error. it turned out I was supposed to be posting an array instead: [{"date":"2013-04-05","value":3}] corrected the error.

so to expand aisrael's answer, make sure the type of what you're giving the program at the other end is what is expected.

Upvotes: 0

Alistair A. Israel
Alistair A. Israel

Reputation: 6567

number_with_precision expects the second parameter to be an options hash

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

In general, whenever you see "undefined method 'symbolize_keys!'" it means you're passing in some other object or value where Ruby/Rails expects a Hash.

Upvotes: 10

Related Questions