nested-forms

How do you make a form out of a polymorophic table?

孤者浪人 提交于 2019-12-24 10:57:29
问题 I am trying to create a comment that could comment on other comments but are all derived from a single post. What is especially troubling for me is trying to figure out how to make it so that this can all be achieved in the post show and not its edit or new. Is this archtecturally reasonable? That way I can access it via Post.comments , or Comment.comments etc. or Comments.parent My Models: #comment.rb belongs_to :post belongs_to :parent, :class_name => 'Comment' has_many :children, :class

Updating nested forms with existing data in inner form using rails 3

…衆ロ難τιáo~ 提交于 2019-12-24 09:36:43
问题 I'm trying to get a nested form view to update properly. This is however causing problems when the second form has existing data. I'm using accepts_nested_attributes_for and nested_form_for. The second which only purpose is to dynamically add the form element using js. See github for more The error I'm getting is: Couldn't find Muscle with ID=3685340 for Exercise with ID=212831413 I've tried to manually do the updating but my code didnt really work and I'm under the impression that it

Rails Nested Forms Not Updating

浪尽此生 提交于 2019-12-24 08:17:16
问题 I'm having a problem getting update_attributes to update nested models in my form. I don't have any errors but the nested attributes aren't saving. Here's the relevant code: Users model: class User < ActiveRecord::Base has_many :orders has_many :achievements accepts_nested_attributes_for :achievements Achievements model: class Achievement < ActiveRecord::Base belongs_to :user Edit User form: <%= form_for @user, :html => { :multipart => true } do |f| %> ... <%= f.fields_for :achievements do |

Rails 5, Cocoon Gem - nested form inside nested form

孤街浪徒 提交于 2019-12-24 06:37:37
问题 I am trying to use cocoon gem to build nested forms. I have models for Organisation, Package::Bip and Tenor. The associations are: Organisation has_many :bips, as: :ipable, class_name: Package::Bip accepts_nested_attributes_for :bips, reject_if: :all_blank, allow_destroy: true Package::Bip (polymorphic) belongs_to :ipable, :polymorphic => true, optional: true, inverse_of: :bip has_one :tenor, as: :tenor accepts_nested_attributes_for :tenor, reject_if: :all_blank, allow_destroy: true Tenor

“stack level too deep” When Processing Carrierwave Image Versions in Nested Form

别说谁变了你拦得住时间么 提交于 2019-12-24 03:23:20
问题 This is a strange problem and, unfortunately, it has many potential sources. I am using carrierwave and cocoon gems to help with nested file uploads. Any type of version processing I do in my uploader causes a stack level too deep error. If I remove the processing, it saves the nested images normally. I have tried to do a lot of troubleshooting and have narrowed it down to that; for example, if I remove just the version processing, then it works normally. If I remove everything except the

nested forms and one to one relationship

两盒软妹~` 提交于 2019-12-24 02:31:27
问题 I have a one-to-one relationship between user and goal. I want to build a form that shows the goal of a user. The problem is that my code only works when the user already has a goal defined. The text field is not rendered when no goal is present. <%= user_builder.fields_for :goal do |goal_builder| %> <%= goal_builder.text_field :goal %> <% end %> Does Rails provide an easy way to do this? 回答1: This is how I would do it : class User < ActiveRecord::Base has_one :goal accepts_nested_attributes

Nested form: shouldn't save if no information for child is entered

我的梦境 提交于 2019-12-24 02:22:48
问题 I have a nested form to sign up a new organization and 1 member (1:many relationship between organization and its members). Both have validations in the model file and the migration file. The issue : I would like the form not to sign up anything (not organization nor member) if not information for both are entered correctly. Currently, when I sign up a new organization but leave all the variables for the member empty it signs up the organization without an error message and it signs up no

nested_form gem add works but remove fails…why?

杀马特。学长 韩版系。学妹 提交于 2019-12-23 12:42:28
问题 I'm using the madebydna version of Ryan Bates' nested_form gem from GitHub (can be found at https://github.com/madebydna/nested_form). I'm using the forked version for jQuery support as opposed to Prototype. UPDATE: Check the bottom of the page for an update to this question. EDIT: I'm using: RoR v3.0.5, jQuery v1.4.3, Ruby v1.9.2 END EDIT EDIT: It appears the current structure of the pictures_attributes parameter passed along to the server is causing an issue, at least from what I've seen on

nested form with polymorphic models

夙愿已清 提交于 2019-12-23 12:39:08
问题 I'm making an app with the following attributes, and I'm working on a creating a single form to be able to save a goal, a goal's tasks, a goal's milestones, and a milestone's tasks. #app/models/goal.rb has_many :tasks, :as => :achievement has_many :milestones accepts_nested_attributes_for :tasks accepts_nested_attributes_for :milestones #app/models/milestone.rb belongs_to :goal has_many :tasks, :as => :achievement #app/models/task.rb belongs_to :achievement, :polymorphic => true Whenever I

Gmaps4rails - longitude and latitude in database no updated. <nested form>

家住魔仙堡 提交于 2019-12-23 12:26:43
问题 I have a model place with attributes name, state, longitude, and latitude. A model travel_plan has many places. I'm using nested form gem for places in the travel plan form. My problem is that the longitude and latitude were not updated when name and state were updated. In my place.rb belongs_to :travel_plan acts_as_gmappable def gmaps4rails_address "#{name},#{state}" end def gmaps4rails_infowindow "<h4>#{name}</h4>" end 回答1: The answer lies here. These two settings are particularly relevant