fields-for

Why would my form submit only one model's data?

白昼怎懂夜的黑 提交于 2020-01-22 03:43:06
问题 I have a form that is intended to submit two models, the first model has_one of the other model, Student_Detail . Many users on here have helped me with some errors that I encountered already, and now my form submits successfully, but only submits the primary model, Participant . I've submitted the form a few times and it stores all information that is a direct attribute of the Participant model. In active admin the Participant model data populates, but no Student_Detail records exist. In the

Simple_Fields_For: Multiple Blank Lines on a Form

≯℡__Kan透↙ 提交于 2019-12-25 03:19:15
问题 I am trying to get a number of blank lines on a simple form using simple_fields_for but only one line/record displays. This is the code below, the models, controller, and view. class Journal < ActiveRecord::Base has_many :journal_lines end class JournalLine < ActiveRecord::Base belongs_to :journal end class JournalController < ApplicationController def new @organisation = Organisation.find(params[:organisation_id]) @journal = Journal.new @journal.journal_lines = Array.new(5, JournalLine.new)

Rails 4.1 Nested Attributes and Fields For Getting Unpermitted Parameters and Not Saving

笑着哭i 提交于 2019-12-24 00:55:44
问题 Research: Rails 4.0 beta, fields_for not accepting pluralized model_name in one-to-many association, Rails 4 Nested Attributes with fields_for Don't Save to Database First, let's get the most common problem out of the way: incorrectly named attributes parameters for strong parameters. Mine is correctly plural. class AdultsController < ApplicationController ... def update authorize @user respond_to do |format| if @user.update_attributes(user_params) format.html { redirect_to unit_adult_path(

Rails 4 Nested Attributes with fields_for Don't Save to Database

不羁的心 提交于 2019-12-24 00:04:22
问题 I want to create records on two different tables (venue and parking) via one form using accepts_nested_attributes_for. I want a user to be able to create a new venue, and also specify the parking options available to that venue via checkboxes. When I submit the form, the record for the containing model (venue) is created, but nothing happens with the nested model (parking). When I check the response from the server, I see that I'm encountering "Unpermitted parameters: parking_attributes,"

Rails - Attaching image through paperclip on nested fields causes unwanted/unavoidable redirect_to

谁说胖子不能爱 提交于 2019-12-23 05:12:04
问题 I have a form in my project for a model Artworks where I am using fields_for for a resource Photo where Artworks has_many :photos . The Photo model uses paperclip to attach images. All my forms are AJAX based, meaning the page should never be reloaded, and I shouldn't be using redirect_to anywhere in my controllers (and I'm not). When I include the fields_for in my form with the paperclip file_field, if I create or update the photo when I submit the form, I get the following error: Template

unknown attribute on polymorphic nested form object creation

断了今生、忘了曾经 提交于 2019-12-23 02:36:47
问题 I am trying to create an associated polymorphic object through fields_for. I am getting an unknown attribute error though when the parent is created, are the @order params not getting through somehow? Parent/Order controller - # GET /orders/new def new @order = Order.new @order.build_patient @order.product = OrthosisSpecification.new end # GET /hotels/1/edit def edit @order.build_patient end # POST /orders # POST /orders.json def create @order = Order.new(order_params) respond_to do |format|

Rails 5 fields_for only sends last params

倾然丶 夕夏残阳落幕 提交于 2019-12-22 18:10:29
问题 I have been hitting my head against a brick wall so it is time to seek smarter people. I am trying to create multiple records of one model using form_tag and fields_for. I have been following all the help/issues/guides I can find but it doesn't seem to work for me. I am wondering if it something that changed going to Rails 5 but more likely it is me. Basically I want a new/create version of the task system listed at the bottom of the api page, similar to this guys puppy creator. The "new"

Fields_for disappear when adding accepts_nested_attributes_for

廉价感情. 提交于 2019-12-21 03:53:08
问题 I'm doing a nested form in Rails 3.2.5, but when I add the accepts_nested_attributes_for my fields_for disappear (they just stop showing in my form). This are my models: class Product < ActiveRecord::Base attr_accessible :title, :description, :variants_attributes has_many :variants accepts_nested_attributes_for :variants validates :title, presence: true end My second model is class Variant < ActiveRecord::Base belongs_to :product attr_accessible :price, :sku, :weight, :inventory_quantity,

Rails: fields_for with index?

拟墨画扇 提交于 2019-12-17 03:55:47
问题 Is there a method (or way to pull off similar functionality) to do a fields_for_with_index ? Example: <% f.fields_for_with_index :questions do |builder, index| %> <%= render 'some_form', :f => builder, :i => index %> <% end %> That partial being rendered needs to know what the current index is in the fields_for loop. 回答1: This would actually be a better approach, following Rails documentation more closely: <% @questions.each.with_index do |question,index| %> <% f.fields_for :questions,

Rails: fields_for with index?

一曲冷凌霜 提交于 2019-12-17 03:55:28
问题 Is there a method (or way to pull off similar functionality) to do a fields_for_with_index ? Example: <% f.fields_for_with_index :questions do |builder, index| %> <%= render 'some_form', :f => builder, :i => index %> <% end %> That partial being rendered needs to know what the current index is in the fields_for loop. 回答1: This would actually be a better approach, following Rails documentation more closely: <% @questions.each.with_index do |question,index| %> <% f.fields_for :questions,