Q:

Ruby on Rails - Store params to database

I have this Hash params from a POST request (it is an ActionController::Parameters) :
{"mc_gross"=>"1.00", "invoice"=>"28", "protection_eligibility"=>"Eligible", "address_status"=>"unconfirmed", "payer_id"=>"FSXBUQDGG6KWN", "tax"=>"0.00", "address_street"=>"Av. de la Pelouse, 87648672 Mayet", "payment_date"=>"14:46:27 Oct 27, 2014 PDT", "payment_status"=>"Completed", "charset"=>"windows-1252", "address_zip"=>"75002", "first_name"=>"St\xE9phane", "mc_fee"=>"0.34", "address_country_code"=>"FR", "address_name"=>"St\xE9phane XXX", "notify_version"=>"3.8", "custom"=>"", "payer_status"=>"verified", "business"=>"stephaneXXXX@gmail.com", "address_country"=>"France", "address_city"=>"Paris", "quantity"=>"1", "verify_sign"=>"AumOxKSV7Re473t76kESkdv3agufAX.VzyW2dEiO-ul3gPNvbfQLzqXq", "payer_email"=>"zXXXXXXX@k.com", "txn_id"=>"8MB257669F3772042", "payment_type"=>"instant", "last_name"=>"XXXX", "address_state"=>"Alsace", "receiver_email"=>"stephaneXXXXXX@gmail.com", "payment_fee"=>"0.34", "receiver_id"=>"ZNER97N82WKY2", "txn_type"=>"web_accept", "item_name"=>"XXXX", "mc_currency"=>"USD", "item_number"=>"1", "residence_country"=>"FR", "test_ipn"=>"1", "handling_amount"=>"0.00", "transaction_subject"=>"", "payment_gross"=>"1.00", "shipping"=>"0.00", "ipn_track_id"=>"5db890c138b56", "controller"=>"purchases", "action"=>"hook"}

I want to save it in my database. What is the best way to do that ?
I tried converting it to a String with params.inspect but it doesn't work, I also tried serialize(params) but failed too.
My column is a t.text, when I do @purchase.update_attributes my_column: params as it is, I get the error : ArgumentError (invalid byte sequence in UTF-8)
Thanks

A:

After multiple tries without any success I decided to bypass the issue.
Since by database field is a text column, what I did is to create a String of all my parameters. After that, I was able to store my String into my text field database column.
parameters = String.new
params.each do |key, value|
  parameters += key + " = " + value + " | "
end

