Tag: formtastic

Rails 3,嵌套的多级表单和has_many通过

我试图让它工作,但它不是! 我有 class User :event_users has_many :event_users accepts_nested_attributes_for :event_users end class Event :event_users accepts_nested_attributes_for :users end class EventUser < ActiveRecord::Base set_table_name :events_users belongs_to :event belongs_to :user accepts_nested_attributes_for :events accepts_nested_attributes_for :users end 还有表格布局 event_users user_id event_id user_type events id name users id name 这是我的forms ‘participating’ %> 问题是如果我以这种方式创建一个新用户,它不会设置user_type的值(但它会创建一个用户和一个带有user_id和event_id的event_users)。 如果我在创建用户并提交后返回编辑表单,则在events_users中设置user_type的值。 (我也尝试过没有formtastic)任何建议? 谢谢! – – 编辑 – – 我也尝试过在用户之前使用event_users […]

访问formtastic中的表单对象

所以我正在制作一个调查应用程序。 用户在后端选择一种表单,并在前端显示为某种类型。 当然,这只是理想情况。 现在发生的事情是我无法访问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