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.
Ukrit H. (Guest)
on 2009-01-05 12: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!!
Ukrit H. (Guest)
on 2009-01-06 03:57
Ukrit H. 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?
rp8 -. (Guest)
on 2009-01-06 04: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
Ukrit H. (Guest)
on 2009-01-06 04: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?
rp8 -. (Guest)
on 2009-01-06 04:44
Ukrit H. 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
Ukrit H. (Guest)
on 2009-01-06 05:05
rp8 -_- wrote:
> Ukrit H. 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'] ?
Eric (Guest)
on 2009-01-06 10: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 H. <removed_email_address@domain.invalid>
cpr (Guest)
on 2009-01-06 16:39
(Received via mailing list)
This topic is locked and can not be replied to.