以 formattastic 访问表单对象
所以我正在制作一个调查应用程序。用户在后端选择一种表单类型,并在前端显示为某种类型。当然,这只是理想情况。现在发生的情况是我无法访问 formtastic 正在为其构建表单的对象。我该怎么说“question.kind”之类的东西?这样只会犯错误。到目前为止,这是我所拥有的......
= semantic_form_for @survey, :url => "#", :html => { :method => "get" } do |f|
- for question in @survey.questions
= user_facing_question(f)
补充辅助方法到目前为止是这样的:
def user_facing_question(f)
f.inputs
end
So I'm making a survey app. The users choose a type of form on the backend, and it displays as a certain type on the front end. That's only ideally, of course. What happens now is I can't access the object formtastic is building the form for. How can I say something like "question.kind"? It just makes an error that way. Here's what I have so far...
= semantic_form_for @survey, :url => "#", :html => { :method => "get" } do |f|
- for question in @survey.questions
= user_facing_question(f)
and the complementary helper method goes like this so far:
def user_facing_question(f)
f.inputs
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以访问表单的对象,例如:
You can access the form's object like: