Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I try to parse text from text area for making array and save him to DB (postgresql) and getting next error:

PG::InvalidTextRepresentation: ERROR: malformed array literal: "{{}}" : UPDATE "categories" SET "advanced_params" = $1, "updated_at" = $2 WHERE "categories"."id" = 8

_form.html.erb:

<%= f.text_area :advanced_params %>

category.rb:

class Category < ActiveRecord::Base
before_save :parse_category_params

protected
    def parse_category_params
        self.advanced_params = advanced_params.split("/, /")
    end
end

schema.rb:

create_table "categories", force: true do |t|
    t.string   "name"
    t.string   "url"
    t.string   "advanced_params",     array: true
    t.datetime "created_at"
    t.datetime "updated_at"
end

Text area data for example: 1234, check, sometext

UPD:

Log output:

SQL (0.9ms)  UPDATE "categories" SET "advanced_params" = $1, "updated_at" = $2 WHERE "categories"."id" = 8  [["advanced_params", "{{}}"], ["updated_at", "2014-08-12 22:28:59.917767"]]
PG::InvalidTextRepresentation: ERROR: malformed array literal: "{{}}"
share|improve this question
2  
Using params for a field name is asking for trouble. The name params is already used for the GET or POST parameters hash. –  Gene 22 hours ago
    
Ok, i change field name to advanced_params, but it's not helping –  CannyFoxx 21 hours ago
1  
Might be bug in Rails, check your version: stackoverflow.com/questions/22596826/… –  seph 20 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.