How do I convert string/text from column to hash?

Hello All…

I am newb in RoR, i have problem to convert data from database to hash.
Example:

  • before I save data to MySQL DB to column ‘budget_list’, the hash is :
    @market_budget = [[BMW5, 2007-12-26, 30000], [BMW3, 2007-12-31,
    150000], [HONDA1, 2007-12-19, 10000], [HONDA2, 2007-12-31, 10000],
    [JAGUAR5, 2007-12-28, 50000], [JAGUAR11, 2007-12-18, 70000]]

  • Data after stored in column ‘budget_list’ with text type data in MySQL
    DB:


    • 101
    • BMW5
    • 2007-12-26
    • 30000
    • 102
    • BMW3
    • 2007-12-31
    • 150000
    • 22
    • HONDA1
    • 2007-12-19
    • 10000
    • 23
    • HONDA2
    • 2007-12-31
    • 10000
    • 26
    • JAGUAR5
    • 2007-12-28
    • 50000
    • 27
    • JAGUAR11
    • 2007-12-18
    • 70000

Now i want call data from column ‘budget_list’ to be like hash again,
before hash stored to db. How I can make data budget_list to be :

@market_budget = [[BMW5, 2007-12-26, 30000], [BMW3, 2007-12-31,
150000], [HONDA1, 2007-12-19, 10000], [HONDA2, 2007-12-31, 10000],
[JAGUAR5, 2007-12-28, 50000], [JAGUAR11, 2007-12-18, 70000]]

Please help me, thank you very much.

FX

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs