Forum: Ruby on Rails Problem with symbols: Value is stored with "--- :symbolname"

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.
74ba9c207c0b60aa996fbc7db1c28cf9?d=identicon&s=25 Carmine Moleti (carminem)
on 2007-05-14 09:27
Hi to everyone,

I've a problem with symbols and my application.
There are 4 fields defined as string which receive a symbol from code:
1. stato (status)
2. fase (phase)
3. spedizione (shipment)
4. pagamento (payment)

Well, only the status field shows a weird behaviour.
There is only one point, so far, in the source where I assign a value to
that
field and the code I wrote is:

  def conferma
    @order = Order.find(session[:ordine])
    @order.stato = :confermato
    @order.save!
    empty_cart
  end

Now, when I read back the order for display purposes, when the field
"stato" is
displayed, something like: "--- :value" is shown.

This thing doesn't happen to the rest above mentioned fields.

Here follows the migration stuff:

    create_table :orders do |t|
      t.column :user_id, :integer
      t.column :user_ip, :string
      t.column :created_at, :timestamp
      t.column :updated_at, :timestamp
      t.column :stato, :string, :default => 'aperto'
      t.column :fase, :string
      t.column :spedizione, :string, :default => 'pacco1'
      t.column :pagamento, :string, :default => 'bonifico'
      t.column :indirizzo, :string
      t.column :civico, :integer
      t.column :cap, :integer
      t.column :comune, :string
      t.column :provincia, :string
      t.column :telefono, :string
      t.column :email, :string
      t.column :note, :string
    end

Is there anything I could check to fix this thing?
I've tried with grep on the whole source tree to find a possible flaw in
the source code. Still, no luck.

Thanks in advance for your help.
74ba9c207c0b60aa996fbc7db1c28cf9?d=identicon&s=25 Carmine Moleti (carminem)
on 2007-05-14 11:39
Nevermind, just figured out that a simple "serialize(attribute_name)" in
the class solved the problem.

Thanks anyway.
This topic is locked and can not be replied to.