Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No multiplier option for Field::Number. #520

Closed
tristandunn opened this issue Mar 15, 2016 · 0 comments
Closed

No multiplier option for Field::Number. #520

tristandunn opened this issue Mar 15, 2016 · 0 comments

Comments

@tristandunn
Copy link
Contributor

The customizing dashboards documentation mentions using a multiplier to display a currency value stored in cents. As far as I can tell that's not actually possible.

I'm guessing it should be something close to the code below. Unsure if it should attempt any casting or type checking though.

module Administrate
  module Field
    class Number < Field::Base
      def to_s
        if data.nil?
          "-"
        else
          format_string % value
        end
      end

      protected

      def value
        data * options.fetch(:multiplier, 1)
      end
    end
  end
end
mattscilipoti pushed a commit to mattscilipoti/passport_scheduler that referenced this issue May 17, 2016
In reviewing issue, noticed that multiplier option was NOT working.  Sure enough, this code didn’t need it. thoughtbot/administrate#520
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants