0
활성 레코드 안에 데이터를 설정하는데 이상한 문제가 있습니다 .. 메소드 내부에서 데이터를 설정하려고해도 아무런 영향을 미치지 않습니다.레일스에서 데이터 설정하기
여기에! 내 수업 클래스 '로
class Option < ActiveRecord::Base
serialize :returns_policy_refunds, Array
def reloadRefundOptions!
@returns_policy_refunds = WebSite.get_refund_options #options array
end
end
간단한입니까?
는 방법은을 설정 내가 .. BLOCK2 같이 BLOCK1에서 동일하게 볼 수 을 기대 .. 이제 .. 난 그냥 화면에 데이터를 뱉어있어[email protected] do |option|
- option.returns_policy_refunds = ["wtf"] #just to reset things
<b>BLOCK 1</b>
= option.reloadRefundOptions!
= option.returns_policy_refunds
<br>
<b>BLOCK 2</b>
= option.returns_policy_refunds = WebSite.get_refund_options
= option.returns_policy_refunds
를 직렬화를 테스트하려면 반환 정책 .. 첫 번째 옵션에서 실제로 볼 수있는 것 .returns_policy_refunds는 [ "wtf"]
무엇이 누락 되었습니까? 나는 틀린 일을해야 할 것이다. 그러나 나는 무엇을 모르고있다. 의견이 있으십니까?
기쁨이 아닙니다. 나는 그 b4를 시도했지만 지금도 시도했습니다. 나는 아직도 내 출력에서 WTF를 본다. – baash05
나는 내 코드를 http://tmonrails.wordpress.com/2009/08/05/ruby-setter-and-getter-methods/ – baash05
에서 발견했다. 본인. 답입니다. – baash05