English 中文(简体)
铁路日期:当选
原标题:rails date_select

现在 我挽救了我以毫米/d/yyy格式拼凑的日期,但希望迄今改换——当选,但我因某种原因留下错误。

Here is the code that I am using
the form

 <%= f.date_select :start_date %>

模型

 validates :start_date, :presence => true

但是,我从我的控制人员那里看到了一个错误,说这符合准绳。

最佳回答

这是因为铁路自动检查数据库一栏,以显示哪类物体将存放在那里。 在此情况下,铁路公司正在寻找一个与电离器日期同时使用的日记栏,而是找到一个var子。

我将进行移徙,以降低起首栏,并把它作为时段重新编号。

创造新的移民:

rails generate migration [name of your migration]

在你的情况下,情况如下:

rails generate migration change_start_date_column_to_timestamp

这将在您的RAILS_中产生一个文件。 ROOT/db/migrations 倍数。

class ChangeStartDateColumnToTimestamp < ActiveRecord::Migration
  def self.up
  end

  def self.down
  end
end

你们需要加以修改,以便研究:

class ChangeStartDateColumnToTimestamp < ActiveRecord::Migration
  def self.up
    remove_column :table_name, :start_date
    add_column :table_name, :start_date, :timestamp
  end

  def self.down
    remove_column :table_name, :start_date
    add_column :table_name, :start_date, :string
  end
end

然后,当铁路从数据库中提取数据时,它便自动将数据转换到Rub Time的物体。

谨慎之词......这将摧毁从头开始的数据。 因此,如果你有需要保存的原有信息,你需要做一些更复杂的事。

问题回答

暂无回答




相关问题
Mysql compaire two dates from datetime?

I was try to measure what is faster and what should be the best way to compare two dates, from datetime record in MySql db. There are several approaches how to grab a date from date time, but I was ...

iPhone Date Picker rolls over to 2010 on December 27th?

So I implemented a UIDatepicker in one of my applications for scheduling and autodialing teleconferences... everything is pretty much ready to go except, while testing I noticed that when the date ...

Convert date Python

I have MMDDYY dates, i.e. today is 111609 How do I convert this to 11/16/2009, in Python?

specifying date format when using $form->inputs() in CakePHP

I am wondering if there is a way to specify the date format in the forms created using CakePHP s $form->inputs(); Please note that this is not the individual $form->input() but instead $form->inputs() ...

NSDateFormat, super simple! Where am I screwing up?

Ok, this is really simple, maybe I m a getting a bit burnt out, but seems like it should work, Query XML feed, put out date string, format, display in a cell. The issue is I m a getting a NULL ...

sqlite writing a date into an email

I am exporting a date value from sqlite and placing it into an email. The date appears like this 279498721.322872 I am using Objective C in an Iphone App. Does anyone know how to make this export ...

热门标签