Ruby on rails 日期下拉问题(格式)
我正在RubyonRails(cloud9)中创建一个web应用程序 我为用户提供了请假选项Ruby on rails 日期下拉问题(格式),ruby-on-rails,ruby,date,Ruby On Rails,Ruby,Date,我正在RubyonRails(cloud9)中创建一个web应用程序 我为用户提供了请假选项 离开日期和返回日期 假日管理员: require 'date' 节假日_form.html.err: <%= f.label :date_leave %><br> <%= f.date_select("date_leave", order: [:day,:month,:year]) %> <%= f.label :date_retu
离开日期
和返回日期
假日管理员:
require 'date'
节假日_form.html.err:
<%= f.label :date_leave %><br>
<%= f.date_select("date_leave", order: [:day,:month,:year]) %>
<%= f.label :date_return %><br>
<%= f.date_select("date_return", order: [:day,:month,:year]) %>
如果我尝试编辑,则会出现以下错误:
undefined method `year' for "{1=>2015, 2=>9, 3=>20}":String
有人对这个问题有什么想法吗
class CreateHolidays < ActiveRecord::Migration
def change
create_table :holidays do |t|
t.string :booking_Id
t.string :Employee_number
t.string :leave_Request_Type
t.string :date_leave
t.string :date_return
t.integer :total_days
t.timestamps null: false
end
end
end
def update
respond_to do |format|
if @holiday.update(holiday_params)
format.html { redirect_to @holiday, notice: 'Leave request was successfully updated.' }
format.json { render :show, status: :ok, location: @holiday }
else
format.html { render :edit }
format.json { render json: @holiday.errors, status: :unprocessable_entity }
end
end
end
class CreateHolidays
向我们显示假日数据库迁移和假日代码#更新操作。日期的数据库列必须是日期
,而不是字符串
。是的,这就解决了问题。非常感谢你的帮助。对于具有相同问题“rake db:rollback”的任何其他人,请编辑您的表,然后再次迁移“rake:dbmigrate”
class CreateHolidays < ActiveRecord::Migration
def change
create_table :holidays do |t|
t.string :booking_Id
t.string :Employee_number
t.string :leave_Request_Type
t.string :date_leave
t.string :date_return
t.integer :total_days
t.timestamps null: false
end
end
end
def update
respond_to do |format|
if @holiday.update(holiday_params)
format.html { redirect_to @holiday, notice: 'Leave request was successfully updated.' }
format.json { render :show, status: :ok, location: @holiday }
else
format.html { render :edit }
format.json { render json: @holiday.errors, status: :unprocessable_entity }
end
end
end