【发布时间】:2016-04-20 07:52:13
【问题描述】:
您好,我有模型 bought_details 和 entry_types。
# Table name: bought_details
#
# id :integer not null, primary key
# bought_data :date not null
# end_on :date not null
# entry_type_id :integer
# person_id :integer
# start_on :date
# cost :decimal(5, 2) not null
# Table name: entry_types
#
# id :integer not null, primary key
# kind :string not null
# kind_details :string not null
# description :text
# price :decimal(5, 2) not null
我想拥有什么:
如果我注册新购买,例如id 1 的人购买通行证(entry_type id:1)1 个月(start_on:20.04.2016 end_on:20.05.2016)。
当 start_on 或 end_on 在 20.04.2016 和 20.05. 2016 年。只需提醒“您已经拥有有效的通行证”。
如何解决我的问题? 提前致谢。
【问题讨论】:
-
请显示到目前为止您尝试了什么。
-
你可以在你的模型上定义一个验证函数,比如this。
-
约会之后的
r.是什么? -
@Stefan 这是一年的波兰语翻译。
标签: ruby-on-rails ruby validation