This project is archived and is in readonly mode.
from_xml and from_json don't work
-
timuckun
Looks like the errors due to cut and paste. Still doesn't update the record though.
u = User.find(3)
=> #tm_user@panztel.com", crypted_password: "b695db100847aa269fb477443a289d875cf2e001", salt: "1e3a4ba1ccb233c2bbd92c3bdbb917307523671b", timezone: "UTC", remember_token: nil, remember_token_expires_at: nil, activation_code: "bab0c2bc67d43b6871005559b114b9b62b7b70bb", activated_at: "2008-11-19 22:12:07", password_reset_code: nil, enabled: true, created_at: "2008-11-19 22:12:07", updated_at: "2008-11-19 22:12:07", lock_version: 4, address_id: nil>
u.to_xml
=> "<?xml version="1.0" encoding="UTF-8"?>\n\n <activated-at type="datetime">2008-11-19T22:12:07Z</activated-at>\n <activation-code>bab0c2bc67d43b6871005559b114b9b62b7b70bb</activation-code>\n <address-id type="integer" nil="true"></address-id>\n <company-id type="integer">3</company-id>\n <crypted-password>b695db100847aa269fb477443a289d875cf2e001</crypted-password>\n tm_user@panztel.com\n true\n 3\n <lock-version type="integer">4</lock-version>\n tm_user\n <password-reset-code nil="true"></password-reset-code>\n <remember-token nil="true"></remember-token>\n <remember-token-expires-at type="datetime" nil="true"></remember-token-expires-at>\n 1e3a4ba1ccb233c2bbd92c3bdbb917307523671b\n UTC\n\n"
Change the XML. Change the timezone from UTC to ABC
a = "<?xml version="1.0" encoding="UTF-8"?>\n\n <activated-at type="datetime">2008-11-19T22:12:07Z</activated-at>\n <activation-code>bab0c2bc67d43b6871005559b114b9b62b7b70bb</activation-code>\n <address-id type="integer" nil="true"></address-id>\n <company-id type="integer">3</company-id>\n <crypted-password>b695db100847aa269fb477443a289d875cf2e001</crypted-password>\n tm_user@panztel.com\n true\n 3\n <lock-version type="integer">4</lock-version>\n tm_user\n <password-reset-code nil="true"></password-reset-code>\n <remember-token nil="true"></remember-token>\n <remember-token-expires-at type="datetime" nil="true"></remember-token-expires-at>\n 1e3a4ba1ccb233c2bbd92c3bdbb917307523671b\n ABC\n\n"
Apply it back to the record.
u.from_xml(a)
u.from_xml(a)
=> #tm_user@panztel.com", crypted_password: "b695db100847aa269fb477443a289d875cf2e001", salt: "1e3a4ba1ccb233c2bbd92c3bdbb917307523671b", timezone: "UTC", remember_token: nil, remember_token_expires_at: nil, activation_code: "bab0c2bc67d43b6871005559b114b9b62b7b70bb", activated_at: "2008-11-19 22:12:07", password_reset_code: nil, enabled: true, created_at: "2008-11-19 22:12:07", updated_at: "2008-11-19 22:12:07", lock_version: 4, address_id: nil>
Mmmmm. timezone is still UTC.
Let's save it.
u.save => true u => #tm_user@panztel.com", crypted_password: "b695db100847aa269fb477443a289d875cf2e001", salt: "1e3a4ba1ccb233c2bbd92c3bdbb917307523671b", timezone: "UTC", remember_token: nil, remember_token_expires_at: nil, activation_code: "bab0c2bc67d43b6871005559b114b9b62b7b70bb", activated_at: "2008-11-19 22:12:07", password_reset_code: nil, enabled: true, created_at: "2008-11-19 22:12:07", updated_at: "2008-11-19 22:12:07", lock_version: 5, address_id: nil>
Looks like the time zone never got changed.
Let's try with json
u.to_json => "{"user": {"salt": "1e3a4ba1ccb233c2bbd92c3bdbb917307523671b", "activated_at": "2008-11-19T22:12:07Z", "remember_token_expires_at": null, "crypted_password": "b695db100847aa269fb477443a289d875cf2e001", "password_reset_code": null, "lock_version": 5, "activation_code": "bab0c2bc67d43b6871005559b114b9b62b7b70bb", "timezone": "UTC", "id": 3, "enabled": true, "address_id": null, "remember_token": null, "company_id": 3, "login": "tm_user", "email": "tm_user@panztel.com"}}" j = "{"user": {"salt": "1e3a4ba1ccb233c2bbd92c3bdbb917307523671b", "activated_at": "2008-11-19T22:12:07Z", "remember_token_expires_at": null, "crypted_password": "b695db100847aa269fb477443a289d875cf2e001", "password_reset_code": null, "lock_version": 5, "activation_code": "bab0c2bc67d43b6871005559b114b9b62b7b70bb", "timezone": "ABC", "id": 3, "enabled": true, "address_id": null, "remember_token": null, "company_id": 3, "login": "tm_user", "email": "tm_user@panztelcom"}}" => "{"user": {"salt": "1e3a4ba1ccb233c2bbd92c3bdbb917307523671b", "activated_at": "2008-11-19T22:12:07Z", "remember_token_expires_at": null, "crypted_password": "b695db100847aa269fb477443a289d875cf2e001", "password_reset_code": null, "lock_version": 5, "activation_code": "bab0c2bc67d43b6871005559b114b9b62b7b70bb", "timezone": "ABC", "id": 3, "enabled": true, "address_id": null, "remember_token": null, "company_id": 3, "login": "tm_user", "email": "tm_user@panztelcom"}}" j => "{"user": {"salt": "1e3a4ba1ccb233c2bbd92c3bdbb917307523671b", "activated_at": "2008-11-19T22:12:07Z", "remember_token_expires_at": null, "crypted_password": "b695db100847aa269fb477443a289d875cf2e001", "password_reset_code": null, "lock_version": 5, "activation_code": "bab0c2bc67d43b6871005559b114b9b62b7b70bb", "timezone": "ABC", "id": 3, "enabled": true, "address_id": null, "remember_token": null, "company_id": 3, "login": "tm_user", "email": "tm_user@panztelcom"}}" u.from_json(j) => #tm_user@panztel.com", crypted_password: "b695db100847aa269fb477443a289d875cf2e001", salt: "1e3a4ba1ccb233c2bbd92c3bdbb917307523671b", timezone: "UTC", remember_token: nil, remember_token_expires_at: nil, activation_code: "bab0c2bc67d43b6871005559b114b9b62b7b70bb", activated_at: "2008-11-19 22:12:07", password_reset_code: nil, enabled: true, created_at: "2008-11-19 22:12:07", updated_at: "2008-11-19 22:12:07", lock_version: 5, address_id: nil> u.save => true u => #tm_user@panztel.com", crypted_password: "b695db100847aa269fb477443a289d875cf2e001", salt: "1e3a4ba1ccb233c2bbd92c3bdbb917307523671b", timezone: "UTC", remember_token: nil, remember_token_expires_at: nil, activation_code: "bab0c2bc67d43b6871005559b114b9b62b7b70bb", activated_at: "2008-11-19 22:12:07", password_reset_code: nil, enabled: true, created_at: "2008-11-19 22:12:07", updated_at: "2008-11-19 22:12:07", lock_version: 6, address_id: nil>
Exact same story.
-
Frederick Cheung
Looks like lighthouse has somewhat mangled what you wrote.
Can you reduce this to a minimal example, where you - take a model - dump the xml - change the xml using gsub (to rule out cut & paste etc...) - load it back in
along with the simplest possible class and the simplest possible schema ?
-
Geoff Buesing
- State changed from new to stale
If this is still an issue, please reopen with 1. a patch, either with a fix, or at least a failing test case, or 2 if you can't generate a patch, the simplest possible example that illustrates this issue, as Frederick suggests.
Please also use Lighthouse's built-in syntax highlighting (see "formatting help" link above "add a comment" text field), it will help others read through your code.
-
CancelProfileIsBroken
- Tag set to bugmash
-
Mike Breen
I cannot reproduce this on 2-3-stable.
-
Rizwan Reza
not reproducible
-1 I followed the steps. May be because my application doesn't show UTC explicitly... I tried changing times but it's not reproducing. It is working as expected for me. May be timuckun should have a demo app at github for this.
-
Derander
Unable to reproduce.
-1
I followed the steps as well. I'm not ruling out copy paste error on my end, but I was unable to see the behavior described.
-
CancelProfileIsBroken
- Tag cleared.
- State changed from stale to invalid
No repro, no more reports of the same behavior, marking invalid.
-
Vimax
This is the thing I'm looking for over the net. Finally I found male enhancement products on the market today. But which of them actually work? With a lot of brands available, Vigrx Plus is the safer to use the mark which is purely natural. Other products is Vimax.