Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8860279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:14:05+00:00 2026-06-14T15:14:05+00:00

I have an App deployed to Heroku, which gives me the below error when

  • 0

I have an App deployed to Heroku, which gives me the below error when trying to create a new Choice in the database. I’m using virtual attributes to handle money in the app as integers. It works just fine on my own machine but when deployed to Heroku to to_d method fails.. why 🙂

2012-11-12 09:48:54+00:00 app web.1 - -
2012-11-12 09:48:54+00:00 heroku router - - POST www.mydomain.com/choices dyno=web.1 queue=0 wait=0ms service=68ms status=500 bytes=643
2012-11-12 09:48:54+00:00 app web.1 - -
2012-11-12 09:48:54+00:00 app web.1 - - Started POST "/choices" for 87.60.190.9/x1-6-00-16-cb-c1-a8-b7.k989.webspeed.com at 2012-11-12 09:48:54 +0000
2012-11-12 09:48:54+00:00 app web.1 - -
2012-11-12 09:48:54+00:00 app web.1 - - NoMethodError (undefined method `to_d' for 6600:Fixnum):
2012-11-12 09:48:54+00:00 app web.1 - - app/models/choice.rb:27:in `value_in_currency'
2012-11-12 09:48:54+00:00 app web.1 - - app/controllers/choices_controller.rb:9:in `create'
2012-11-12 09:48:54+00:00 app web.1 - -
2012-11-12 09:48:54+00:00 app web.1 - -
2012-11-12 09:48:54+00:00 app web.1 - - Processing by ChoicesController#create as HTML
2012-11-12 09:48:54+00:00 app web.1 - - Parameters: {"utf8"=>"✓", "authenticity_token"=>"YygjksxB+1SXnJ8j4jvTtxnh2JfJELpCeHysGrvItcU=", "choice"=>{"spotarea_id"=>"1", "product_id"=>"1", "value_in_currency"=>"66", "exposure"=>"80", "deliverydate"=>"2012-11-13"}, "commit"=>"Create Choice"}
2012-11-12 09:48:54+00:00 app web.1 - - Completed 500 Internal Server Error in 38ms

My Choice model contains the following:

class Choice < ActiveRecord::Base
  belongs_to :user
  belongs_to :spotarea
  belongs_to :product
  has_many   :bets,       :dependent => :destroy

  attr_accessible     :deliverydate, :exposure, :value_in_currency, :user_id, :spotarea_id, :product_id
  attr_accessible     :deliverydate, :exposure, :value_in_currency, :user_id, :spotarea_id, :product_id, as: :admin

  # Validations
  validates   :spotarea, :product, :value_in_currency, :exposure, :presence => { :message => "is missing!" }
  validates   :value_in_currency, :exposure, :numericality => { :message => "is not numeric!" }
  validates   :value_in_currency, :format => { :with => /^\d+\.?\d{0,2}$/, :message => "is not correctly formatted!" }

  def value_in_currency
    value.to_d/100 if value?
  end

  def value_in_currency=(currency)
    self.value = currency.to_d*100 if currency.present?
  end
end

EDIT:

I think I found a solution. I rewrote the code, so it now contains the below instead. Still can’t see why the to_d don’t work..

def value_in_currency
  BigDecimal(value.to_s)/100 if value?
end

def value_in_currency=(currency)
  self.value = BigDecimal(currency.to_s)*100 if currency.present?
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:14:06+00:00Added an answer on June 14, 2026 at 3:14 pm

    I think I found a solution. I rewrote the code, so it now contains the below instead. Still can’t see why the to_d don’t work..

    def value_in_currency
      BigDecimal(value.to_s)/100 if value?  
    end
    
    def value_in_currency=(currency)
      self.value = BigDecimal(currency.to_s)*100 if currency.present?
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have an app deployed on Heroku which runs on two web dynos
I have an existing Rails app on GitHub and deployed on Heroku. I'm trying
I'm pretty new to ROR. I've recently deployed an app on heroku and have
I have deployed a rails app on Heroku, and I am using the twitter-bootstrap-rails
I have a Rails app deployed on Heroku with the Heroku scheduler add-on successfully
I have a J2EE app deployed as an EAR file, which in turn contains
I have a click-once deployed app that uses a notification icon created using the
I have deployed a Django 1.3.1 app on apache2 in my machine using mod_wsgi
So I have deployed my app to heroku for testing for a couple of
Is it feasible to have a Ruby on Rails app, which is: a) deployed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.