nested-forms

Nested model validation - errors don't show

吃可爱长大的小学妹 提交于 2020-01-01 11:55:15
问题 There have been many questions about this, but none of them seem to help. And yes, I have watched this rails cast. I have an Author who has many Books, like so: Author: class Author < ActiveRecord::Base attr_accessible :name has_many :books, dependent: :destroy accepts_nested_attributes_for :books, allow_destroy: true validates :name, presence: true validates :name, length: { minimum: 3 } end Book: class Book < ActiveRecord::Base attr_accessible :name, :year belongs_to :author validates :name

Rails - How to manage nested attributes without using accepts_nested_attributes_for?

放肆的年华 提交于 2020-01-01 03:15:15
问题 My problem is I've run into limitations of accepts_nested_attributes_for, so I need to figure out how to replicate that functionality on my own in order to have more flexibility. (See below for exactly what's hanging me up.) So my question is: What should my form, controller and models look like if I want to mimmic and augment accepts_nested_attributes_for? The real trick is I need to be able to update both existing AND new models with existing associations/attributes. I'm building an app

Rails Nested Forms With Images

佐手、 提交于 2020-01-01 02:35:18
问题 So I'm building a nested form with an Campaigns model and a Sites model where Campaigns has_many Sites. In my Campaigns form I have: <%= f.fields_for :sites do |builder| %> <%= render "site_fields", :f => builder %> <% end %> And then in the _site_fields.html.erb I have: <div class="field"> <%= f.label :title %><br /> <%= f.text_field :title %> </div> <%= f.label "Image"%><br> <%= f.file_field :image %> <div class="field"> <%= f.label :url %><br> <%= f.text_field :url %> </div> This all seems

Adding dynamic fields to nested form through AJAX

*爱你&永不变心* 提交于 2019-12-31 22:02:10
问题 I've been watching and reproducing these railscasts on my app: 196-nested-model-form-part-1 and 197-nested-model-form-part-2. I do not yet have a pro account so i can't watch the revised episode. I'm developing under rails4 (edge) and link_to_function has been deprecated in favor of unobstrusive JS (which is great). I'll keep the example of the above railscasts (i.e. survey/question). What i'd like to do is to use the question's partial through unobstrusive javascript and i just don't know

Rails 4 - Nested form with accepts_nested_attributes_for controller setup?

荒凉一梦 提交于 2019-12-28 18:39:52
问题 I'm trying to make a nested form with form_for and fields_for . After much research and in-success, not working on my project anymore. I'm just trying to recreate a railscast to see what have I done wrong. I'm trying to re-create the example found at http://railscasts.com/episodes/196-nested-model-form-part-1 which shouldn't be that hard since the code is there, but I can't manage to create questions from the survey. Here is my code until now: rails new surveysays rails g scaffold survey name

Rails with nested form

百般思念 提交于 2019-12-25 18:21:50
问题 When I submit the form it creates the new Outfitter, but it does not create a new User. In the log it says 'Unpermitted parameters: utf8, authenticity_token, first_name, last_name, email, password, password_confirmation, commit' Modal html:(modal is in application.html.erb. Page is localhost:3000/pages/index) <div id="popup-outfitter-signup" class="modal popup"> <div class="modal-main rounded-10px"> <div class="modal-title"> Create your Outfitter<br/> </div><!-- end .modal-title --> <%=

Unpermitted parameter in Rails 4 when submitted nested attributes, has_many associated form

人盡茶涼 提交于 2019-12-25 07:39:33
问题 I have two models ( lead which has_many :quote_metals and accepts_nested_attributes_for :quote_metals and quote_metal which belongs_to :lead ). I am trying to write the information submitted in the form to the different datatables. There should just be one lead and multiple (no exact number) of quote_metals. I am receiving an error saying that Unpermitted parameter: quote_metal . Here are the parameters: Processing by LeadsController#create as HTML Parameters: {"utf8"=>"✓", "authenticity

Rails nested_form inside nested_form

本秂侑毒 提交于 2019-12-25 07:20:09
问题 I have the following models and relations: 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

Nested form validations not working in rails app

五迷三道 提交于 2019-12-25 04:43:11
问题 My validations are not working for a nested form - messages, which is in other models show page. Here's the code: Reserve Online: <%= form_for([@trip, @trip.messages.build]) do |f| %> <%= render 'shared/error_messages', object: f.object %> <%= f.text_field :name, :class => "span3", :placeholder => "Name:" %> <%= f.text_field :email, :class => "span3", :placeholder => "Email:" %> <div class="h"> <%= f.text_field :subject, :class => "h", :value => (@trip.title) %> </div> <%= f.text_area :body,

edit model using selectbox nested_form gem

假装没事ソ 提交于 2019-12-25 04:31:52
问题 I have a nested form gem issue and can't figure it out for days. When "edit" model, why my selectbox not filled with current value from database? my "customize" view : <%= nested_form_for @order_detail, :url => create_customize_cart_path do |f| %> # some field here <%= f.fields_for :order_customs do |builder| %> <%= render "order_customs_form", :f => builder %> <% end %> <%= f.link_to_add "Add Order Customize", :order_customs %> <%= f.submit %> <%end%> my partial view (as nested) : <%= f