lundi 16 avril 2018

Return checkbox value

I have a form for @invoice_address, and in the form I have two radio buttons for the attribute gender, like this:

= form_for @invoice_address do |f|
  .table-responsive
    %table.table
      %tbody
        %tr
          %td
            = f.radio_button :gender, :value => "De Heer"
            = f.radio_button :gender, :value => "Mevrouw"

What I want to do, is to get the stored value, so either "De Heer" or "Mevrouw". This is how I'm trying to do that:

%td= @invoice_address.gender

The problem is that this returns:

{:value=>"De Heer"}

How can I get rid of {:value=>""} and only get the value?

In case you need it, this is in my schema:

create_table "invoice_addresses", force: :cascade do |t|
  t.string "street"
  t.string "zip"
  t.string "city"
  t.string "country"
  t.string "phone"
  t.string "mobile"
  t.string "firstname"
  t.string "lastname"
  t.string "gender"
  t.datetime "created_at", null: false
  t.datetime "updated_at", null: false
end




Aucun commentaire:

Enregistrer un commentaire