Có thể thêm biểu mẫu lồng vào #show page không?Biểu mẫu lồng nhau ActiveAdmin trên #show trang
Bây giờ tôi có quản trị của tôi/posts.rb:
ActiveAdmin.register Post do
show do |post|
h2 post.title
post.comments.each do |comment|
row :comment do comment.text end
end
end
end
Nó liệt kê tất cả các bình luận cho bài. Bây giờ tôi cần một biểu mẫu để thêm nhận xét mới. Tôi đang cố gắng để làm như thế này:
ActiveAdmin.register Post do
show do |post|
h2 post.title
post.comments.each do |comment|
row :comment do comment.text end
end
form do |f|
f.has_many :comments do |c|
c.input :text
end
end
end
end
và nhận được một lỗi:
undefined method `has_many' for <form></form> :Arbre::HTML::Form
Models cho Bưu Comments trông giống như:
class Post < ActiveRecord::Base
has_many :comments
accepts_nested_attributes_for :comments
end
class Comment < ActiveRecord::Base
belongs_to :post
end
Làm thế nào để tôi thêm hình thức mà đến trang chương trình của tôi? Cảm ơn
Làm cách nào để thêm văn bản nhập liệu cho nhận xét? – WarLord