时间表应用程序的 form_如何在 Rails 中工作
我有以下 ActiveRecord 模型
class User < ActiveRecord::Base
has_many :timesheets
end
class Timesheet < ActiveRecord::Base
belongs_to :user
has_many :work_days
end
class WorkDay < ActiveRecord::Base
belongs_to :timesheet
end
WorkDay
模型具有 hours
、days
、comments
等属性。
我可以不知道这个表单在 Rails 中会是什么样子。我从 Railscasts 看到了一些复杂的表单,但仍然没有得到它。
我正在设想一个如下所示的表单(持续 7 天):
06/19 (Day1) 06/20 (Day2) 06/21 (Day3) ... 06/26 (Day 7)
textfield 1 textfield 2 textfield 3 ... textfield4
<submit>
所以我在此表单中有 7 个文本字段(每个文本字段也可能有注释)。
有人可以告诉我/解释一下 form_for
将如何查找此内容。
I have the following ActiveRecord models
class User < ActiveRecord::Base
has_many :timesheets
end
class Timesheet < ActiveRecord::Base
belongs_to :user
has_many :work_days
end
class WorkDay < ActiveRecord::Base
belongs_to :timesheet
end
The WorkDay
model has attributes like hours
, days
, comments
, etc.
I can not figure out how the form would look like in rails for this.. I saw some complex forms from railscasts but still not getting it.
I am envisioning a form like below (for 7 days):
06/19 (Day1) 06/20 (Day2) 06/21 (Day3) ... 06/26 (Day 7)
textfield 1 textfield 2 textfield 3 ... textfield4
<submit>
So I have 7 textfields in this form (might have comments for each one as well).
Can someone tell me/explain me how the form_for
would look for this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你将会遇到这样的事情——
You will be having something like this -