Tag: 嵌套表单for

在nested_form中的Rails nested_form

我有以下模型和关系: Rate fields t.string :type t.string :name class Rate < ActiveRecord::Base has_many :category_rate_requests end CategoryRateRequests fields t.date :date_from t.date :date_to class CategoryRateRequests < ActiveRecord::Base belongs_to :rate has_many :category_rates end CategoryRate t.integer :room_category_id t.integer :new_rate_id t.integer :category_rate_request_id t.integer :amount class CategoryRate < ActiveRecord::Base belongs_to :rate belongs_to :category_rate_request belongs_to :room_category end 我试图在nested_form中有一个nested_form = nested_form_for @rate do |f| […]

为nil获取未定义的方法`values_at’:使用nested_form_for的NilClass

我正在使用ryanb的nested_form gem,它似乎没有正常工作。 删除链接不起作用(我正确安装了// = require jquery_nested_form,看起来它正在加载,但我不断收到此错误: undefined method `values_at’ for nil:NilClass 当我去添加: = f.link_to_add “Add a line item”, :invoice_line_items 此外,没有该行它可以工作,但删除链接不会做任何事情: line_item.link_to_remove “Remove this line item” 这是我的代码: .row-fluid .span10.offset1 = nested_form_for(@invoice) do |f| – if @invoice.errors.any? #error_explanation %h2 = pluralize(@invoice.errors.count, “error”) prohibited this invoice from being saved: %ul – @invoice.errors.full_messages.each do |msg| %li= msg .fieldset %legend […]

关联无效。 确保accepts_nested_attributes_for用于:问题关联

我正在rails 4中构建嵌套表单。我不断收到此错误 我的_form.html.erb为 prohibited this project from being saved: builder %> _question.html.erb 3 %> project.rb has_many :questions, :dependent => :destroy accepts_nested_attributes_for :questions, :reject_if => lambda { |a| a[:content].blank? }, :allow_destroy => true 编辑 question.rb class Question < ActiveRecord::Base belongs_to :project end 项目控制员 def new @project = Project.new 3.times do question = @project.questions.build end def project_params […]

nested_form,has_many:through,更新连接模型的属性

我正在使用ryan bates的插件nested_form,我一直在尝试为has_many编写表单:通过关系。 我有3个型号: Profile has_many :memberships has_many :organizations, :through => :memberships accepts_attributes_for :organizations attr_accessible :organization_attribtues Membership has_many :profiles has_many :organizations Organization has_many :memberships has_many :profiles, :though => :memberships 下面的表单用于配置文件,但组织嵌套在其中。 我可以通过f.fields_for:组织创建有关组织的信息,但后来我不清楚如何更新特定于组织成员身份的信息。 具体来说,成员资格表上有一个title属性(我在下面评论它,因为它会为组织抛出一个错误的未定义方法`title’)。 任何帮助都会非常感激! 谢谢。 = f.fields_for :organisations do |org| = org.input :name, :label => “Name of the Organization” = org.input :title, :label => “Your role” = […]