是否可以将嵌套表单添加到#show页面?
现在我有我的admin/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
Run Code Online (Sandbox Code Playgroud)
它列出了帖子的所有评论.现在我需要一个表单来添加新评论.我想这样做:
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
Run Code Online (Sandbox Code Playgroud)
并得到一个错误:
<form> </ form>的未定义方法`has_many':Arbre :: HTML :: Form
帖子和评论的模型如下:
class Post < ActiveRecord::Base
has_many :comments
accepts_nested_attributes_for :comments
end
class Comment < ActiveRecord::Base
belongs_to :post
end
Run Code Online (Sandbox Code Playgroud)
如何将该表单添加到我的显示页面?谢谢
可能重复:
Python小数范围()步长值
我在C中有一个循环:
for (float i = 0; i < 2 * CONST; i += 0.01) {
// ... do something
}
Run Code Online (Sandbox Code Playgroud)
我在python中需要相同的循环,但是:
for x in xxx
Run Code Online (Sandbox Code Playgroud)
不一样.
我怎么能在python中创建它?
所以问题很简单:
我想这样做:
$this->call('POST', '/my/route', ['params' => 'array'], [], ['X-Custom' => 'header']);
Run Code Online (Sandbox Code Playgroud)
但是当我打电话给Request::header('X-Custom')
我的控制器时,我没有得到它.是的,它可用Request::server('X-Custom')
,但它不是我需要的.
所以我需要把它搞定Request::header()
.
PS: Laravel 4