Forum: Ruby on Rails [Please help!]store parameters variable into database

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2da46bf3608ac6f8b50db545e267ce5c?d=identicon&s=25 Ukrit Himakoon (ukarick)
on 2009-01-05 11:23
So here's what I'm trying to do
I'm going to store params variables into database.
Here's what it's looklike.


------------------------Data that store on my database --------------
--- !map:HashWithIndifferentAccess
"15": "1"
"16": "1"
2-Medium: "0"
1-High: "1"
3-Low: "0"
---------------------------------------------------------

So I need to call this parameter from database then pass it on the page
once again But It's not like the previous parameter so any idea?

Please help!!
2da46bf3608ac6f8b50db545e267ce5c?d=identicon&s=25 Ukrit Himakoon (ukarick)
on 2009-01-06 02:57
Ukrit Himakoon wrote:
> So here's what I'm trying to do
> I'm going to store params variables into database.
> Here's what it's looklike.
>
>
> ------------------------Data that store on my database --------------
> --- !map:HashWithIndifferentAccess
> "15": "1"
> "16": "1"
> 2-Medium: "0"
> 1-High: "1"
> 3-Low: "0"
> ---------------------------------------------------------
>
> So I need to call this parameter from database then pass it on the page
> once again But It's not like the previous parameter so any idea?
>
> Please help!!

I'm still confused with this problem
I wonder that,Can I convert this kind of variables back to params?
90e7e04c730e1b747288051af34c3bb0?d=identicon&s=25 rp8 -_- (rp8)
on 2009-01-06 03:30
One way is to save a serialized hash into the db and you can deserialize
the saved hash object back to params.

Regards,

rp8
=======================
http://lun.competo.com
2da46bf3608ac6f8b50db545e267ce5c?d=identicon&s=25 Ukrit Himakoon (ukarick)
on 2009-01-06 03:35
rp8 -_- wrote:
> One way is to save a serialized hash into the db and you can deserialize
> the saved hash object back to params.
>
> Regards,
>
> rp8
> =======================
> http://lun.competo.com

How to serialize would you mind giving me some example.
suppose that I've session['test'] which store several params inside
such as
session['test'] = idlist['1']=test&idlist['2']=test2

so I need to store this stuff inside my DB so if I need to serialized
what I have to do?
90e7e04c730e1b747288051af34c3bb0?d=identicon&s=25 rp8 -_- (rp8)
on 2009-01-06 03:44
Ukrit Himakoon wrote:
> rp8 -_- wrote:
>> One way is to save a serialized hash into the db and you can deserialize
>> the saved hash object back to params.
>>
>> Regards,
>>
>> rp8
>> =======================
>> http://lun.competo.com
>
> How to serialize would you mind giving me some example.
> suppose that I've session['test'] which store several params inside
> such as
> session['test'] = idlist['1']=test&idlist['2']=test2
>
> so I need to store this stuff inside my DB so if I need to serialized
> what I have to do?
require 'yaml'

serialized = obj.to_yaml
new_obj = YAML::load(serialized)
puts new_obj.width

Regards,

rp8
=======================
http://lun.competo.com
2da46bf3608ac6f8b50db545e267ce5c?d=identicon&s=25 Ukrit Himakoon (ukarick)
on 2009-01-06 04:05
rp8 -_- wrote:
> Ukrit Himakoon wrote:
>> rp8 -_- wrote:
>>> One way is to save a serialized hash into the db and you can deserialize
>>> the saved hash object back to params.
>>>
>>> Regards,
>>>
>>> rp8
>>> =======================
>>> http://lun.competo.com
>>
>> How to serialize would you mind giving me some example.
>> suppose that I've session['test'] which store several params inside
>> such as
>> session['test'] = idlist['1']=test&idlist['2']=test2
>>
>> so I need to store this stuff inside my DB so if I need to serialized
>> what I have to do?
> require 'yaml'
>
> serialized = obj.to_yaml
> new_obj = YAML::load(serialized)
> puts new_obj.width
>
> Regards,
>
> rp8
> =======================
> http://lun.competo.com

Thx here's what's store inside my db for now

-----------------------------------
--- !map:HashWithIndifferentAccess
2-Medium: "1"
"17": "1"
"18": "1"
3-Low: "1"
1-High: "1"
"20": "0"
"19": "1"
-----------------------------------

It's that correct one? if so how can I call this one back to
session['test'] ?
D93ae163042e0a937941e0ba4d8ed5d7?d=identicon&s=25 Eric (Guest)
on 2009-01-06 09:14
(Received via mailing list)
if those colons (":") are in the db, you have almost-readymade json.

-eric

On Jan 5, 7:05 pm, Ukrit Himakoon <rails-mailing-l...@andreas-s.net>
F7a62f21b0e8b0351742803a2dbcd649?d=identicon&s=25 cpr (Guest)
on 2009-01-06 15:39
(Received via mailing list)
This topic is locked and can not be replied to.