他们有红宝石日期过滤器吗?
1) 我的人力资源管理应用程序中有一个请假申请表,我希望当用户输入“from_date”时,“to_date”应该大于“from_that”?
2) 在我的应用程序中,我有一个休假模型,用户可以在其中定义休假类型和允许的天数。在我的第二个模型中,leave_request 用户可以根据休假类型请求休假。一切正常。现在我想向用户显示可用的休假余额请假请求表单中允许的天数的基础?
迁移leave.rb:
class CreateLeaves < ActiveRecord::Migration
def self.up
create_table :leaves do |t|
t.integer :user_id
t.integer :company_id
t.string :leave_type
t.integer :allowed_leaves
t.text :description, :limit => 500
t.timestamps
end
end
def self.down
drop_table :leaves
end
end
和leave_request.rb:
class CreateLeaveRequests < ActiveRecord::Migration
def self.up
create_table :leave_requests do |t|
t.integer :employee_id
t.integer :leave_type
t.date :from_date
t.date :to_date
t.text :reason_for_leave
t.string :contact_during_leave, :limit => 10
t.integer :user_id
t.integer :company_id
t.timestamps
end
end
def self.down
drop_table :leave_requests
end
end
如果用户没有足够的休假余额,我可以验证可用的休假数量吗?他们应该是一条消息,例如“您没有足够的休假来请求”等。
1)
i have a leave request form in my HRM application, i want that when a user enter the "from_date", the "to_date" should be greater than "from_that"?
2)
In my app i have a leave model in which user can defined leave type and day's allowed.In my second model leave_request user can request for leave according to leave type.Everything is working well.Now i want to display leave balance available to user on basis of allowed day's in leave_request form?
Migration leave.rb:
class CreateLeaves < ActiveRecord::Migration
def self.up
create_table :leaves do |t|
t.integer :user_id
t.integer :company_id
t.string :leave_type
t.integer :allowed_leaves
t.text :description, :limit => 500
t.timestamps
end
end
def self.down
drop_table :leaves
end
end
And leave_request.rb:
class CreateLeaveRequests < ActiveRecord::Migration
def self.up
create_table :leave_requests do |t|
t.integer :employee_id
t.integer :leave_type
t.date :from_date
t.date :to_date
t.text :reason_for_leave
t.string :contact_during_leave, :limit => 10
t.integer :user_id
t.integer :company_id
t.timestamps
end
end
def self.down
drop_table :leave_requests
end
end
And can i validate number of leaves available like if user do not have enough leave balance than their should be a message like"You do not have enough leave to request " etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你的第一个问题不太好理解。什么是“
from_that
”?如果您询问如何检查一个日期是在另一个日期之前还是之后,很简单:Date
和DateTime
包含Comparable
,以便您可以进行比较任意两个就像两个数字一样,例如:Your first question is not very comprehensible. What is "
from_that
"? If you're asking how to check if one date is before or after another, it's easy:Date
andDateTime
includeComparable
so you can compare any two just like you would two numbers, e.g.:我通过以下方式完成了第一个问题:
I have done my first problem in following way:
大家好,这里的朋友们,我对第二个问题有了新的答案
,我使用以下代码行来解决我的问题:
这在我的新的leave_request表单中显示了我的所有leave_types。
Hi friends here i came with a new answer of my second question
i used following line of code to fix my problem:
This displayed all my leave_types in my new leave_request form.