ActiveSupport
옵션 encode_big_decimal_as_string
을 사용하고 싶습니다. 모델에 넣어야합니까? 모델 인스턴스에서이 메서드를 호출합니까? 내가 어딘가 config에 배치합니까? ActiveSupport
옵션은 무엇이며 어떻게 사용할 수 있습니까?ActiveSupport encode_big_decimal_as_string
4
A
답변
-1
나는 당신이 environment.rb
파일에서 그렇게한다고 믿습니다.
이렇게하면 효과가 있습니다. 나는 지금 그것을 시험 할 방법이 없다.
Rails::Initializer.run do |config|
config.active_support.json.encode_big_decimal_as_string = true
end
2
레일 4.0에서는 다음과 같이 application.rb
에 설정할 수 있습니다 : 레일 4.1에서
config.active_support.encode_big_decimal_as_string = false
는 ActiveSupport.encode_big_decimal_as_string
옵션은 사용되지 않습니다. 이 기능은 activesupport-json_encoder 보석으로 추출되었습니다.
7
Rails 4.0에서는 이러한 답변이 나에게 도움이되지 않았습니다. @ 타일러 - 응우 말했다
# config/application.rb
...
module AppName
class Application < Rails::Application
...
ActiveSupport::JSON::Encoding.encode_big_decimal_as_string = false
...
end
end
으로이 레일 4.1 deprecated을되고, 추출 :
ActiveSupport::JSON::Encoding.encode_big_decimal_as_string = false
과 같이, 응용 프로그램 설정에이 줄을 추가 : 여기에 레일 4.0에서 작동하는 것입니다 이 보석에 : ActiveSupport JSON Encoder. 4.1의 설정에 대해서는 gem 문서를 참조하십시오.
+3
레일 4.1의 경우 위의'config/application.rb' 수정 외에도'gem 'activesupport-json_encoder''를 gemfile에 추가하십시오 . –
관련 문제
- 1. ActiveSupport :: HashWithIndifferentAccess는
- 2. ActiveSupport :: Concern and alias_method_chain
- 3. ActiveSupport :: Dependencies.autoload_paths : 열심히로드하는 방법?
- 4. ActiveSupport :: StringInquirer in Rails
- 5. ActiveSupport 시간대에 EST가 없습니다.
- 6. ActiveSupport :: 우려 슈퍼 실종
- 7. ActiveSupport :: JSON.backend = "JSONGem"
- 8. 오이로드 오류 activesupport
- 9. ActiveSupport :: SecureRandom은 어떻게 안전합니까?
- 10. 'Rails'with Activesupport 3.2.0
- 11. ActiveSupport :: Notifications transaction_id
- 12. ActiveSupport :: Notifications가 비동기입니까?
- 13. extend ActiveSupport :: Concern을 사용하십시오.
- 14. ActiveSupport :: Configurable with Rails Engine
- 15. 초기화되지 않은 상수 ActiveSupport :: Memoizable
- 16. 초기화되지 않은 상수 ActiveSupport :: CoreExtensions
- 17. activesupport 루비 1.91에 문제와 레이크는
- 18. 레일스 ActiveSupport NoMethodError from unicode.rb
- 19. Minitest :: Spec과 ActiveSupport :: TestCase의 차이점
- 20. 초기화되지 않은 상수 ActiveSupport :: TestCase에
- 21. ActiveSupport :: Deprecation.silenced = true가 작동하지 않습니까?
- 22. 동등성을위한 ActiveSupport :: TimeWithZone 개체 테스트
- 23. ActiveSupport :: 문제 및 클래스 메서드
- 24. 레일스 ActiveSupport :: TimeZone에서 Country로 변환
- 25. 레일 3.1, ---! map : ActiveSupport :: HashWithIndifferentAccess?
- 26. ActiveSupport :: TimeZone 오프셋 문자열 목록
- 27. ActiveSupport json 출력의 그림 이모전
- 28. ActiveSupport Rescuable - 재 시도가 가능합니까?
- 29. ActiveSupport (레일이없는)가있는 기본 TimeZone
- 30. 이어지고 설치 일정 ActiveSupport :: CoreExtensions
서버를 시작할 때 오류가 발생했습니다 : 초기화되지 않은 Rails :: Initializer (NameError) – Rob