0

嗨,我在 Rails 上使用 ruby​​,当我输入出生日期时,我的出生日期只是从 2007 年到 2012 年,我的数据库上有这个命令,我加粗了给我错误的那个,这是我需要的拥有所有选项来选择出生日期,当然也可以在未来选择它们

class CreatePacientes < ActiveRecord::Migration
  def change
    create_table :pacientes do |t|
      t.string :cedula
      t.string :nombre
      t.string :apellido1
      t.string :apellido2
      **t.date :fecha_nacimiento**
      t.string :genero
      t.string :estado_civil
      t.string :provincia
      t.string :canton
      t.string :distrito
      t.text :otras_senas
      t.string :telefono_casa
      t.string :telefono_celular
      t.string :correo_electronico
      t.string :nacionalidad
      t.integer :anos_estudio
      t.string :profesion
      t.string :ocupacion

      t.timestamps
    end
  end
end
4

1 回答 1

1

如果您查看helper的文档date_select,您会看到它接受以下两个选项:

:start_year - Set the start year for the year select. Default is Time.now.year - 5.

:end_year - Set the end year for the year select. Default is Time.now.year + 5.

您看到的是默认值。虽然我不确定为什么你的最大值是 2012 年,而不是 2017 年,因为它应该是 +/- 5 年。无论如何,尝试通过限制以获得您需要的范围。date_select或者如果您需要输入任何年份,请不要使用。

于 2012-12-11T16:41:59.217 回答