如何使用rails 3和datamapper创建嵌套表单?
我在 Datamapper 中的模型是:
项目:
require "dm-accepts_nested_attributes"
class Project
include DataMapper::Resource
property :id, Serial
property :project_title, String
has n, :tasks
accepts_nested_attributes_for :tasks
end
任务:
class Task
include DataMapper::Resource
property :id, Serial
property :task_name, String
belongs_to :project
end
现在我想为项目创建视图,其中包含用于添加任务的链接。 我用 nested_form gem 尝试过 和 cocoon gem 但没有用。
my models in Datamapper are:
Project:
require "dm-accepts_nested_attributes"
class Project
include DataMapper::Resource
property :id, Serial
property :project_title, String
has n, :tasks
accepts_nested_attributes_for :tasks
end
Task:
class Task
include DataMapper::Resource
property :id, Serial
property :task_name, String
belongs_to :project
end
Now i wanted to create view for the Project with links for adding tasks.
I tried it with nested_form gem
and cocoon gem but no use.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论