nested-forms

rails simple_nested_form_for fields_for wrong number of arguments

时间秒杀一切 提交于 2019-12-08 16:37:43
问题 So I'm building a form in rails 3.1, using <%= simple_nested_form_for(@person, :url => collection_url, :html=>{:multipart => true}) do |f| %> <%= render :partial => "form", :locals => { :f => f } %> <% end %> but this line in the partial is causing the problem: <h2>Badges</h2> <ul id="certifications"> // this following line is raising the error "wrong number of arguments (4 for 3)" <%= f.fields_for :certifications do |certification_form| %> <%= render :partial => 'certification', :locals => {

accepts_nested_attribute_for and multiple edits

亡梦爱人 提交于 2019-12-08 10:39:41
问题 Following on from this answer, I am having a spot of bother with accepts_nested_attributes_for. First things first, this is my error code: undefined method `reflect_on_association' for NilClass:Class line 39 which I get when calling this partial in _formfield.html.haml: 36: = link_to "Edit list", notifications_path 37: %br 38: %li.tip 39: = link_to_add_association 'Add product codes', f, :productcodes 40: = f.semantic_fields_for :productcodes do |productcode| 41: = render 'productcode_fields'

Rails: Access params of a form with a nested model

为君一笑 提交于 2019-12-08 10:28:47
问题 I have the following models class GymUser < ActiveRecord::Base belongs_to :user belongs_to :gym end class User < ActiveRecord::Base has_many :gym_users has_one :gym attr_accessible :gym_users_attributes, :gym_users accepts_nested_attributes_for :gym_users end I have a form for a new user, with a nested model gym_user. I want to make sure the user doesn't exist already. This is what I'm trying: def create_member @user = User.new(params[:user]) @user.generate_password @dupe = User.find_all_by

How to Write a Simple Nested, has_many :through, many-to-many Form in Rails 3.1?

邮差的信 提交于 2019-12-08 05:47:15
问题 I am building a recipe manager as a first rails app. I have a many-to-many, nested set of models based on this quite nice ERD. Ideally, I would like to create a form that allows me to create the recipe in a single form. Also, I would like the user to be able to write/paste the ingredients and steps into a single text field, respectively. In the code below, there is a virtual attribute that parses the cr separated lists in the form to attempt this. I keep getting a "readonly" has_many through

rspec doesn't see fields dynamically added or removed by cocoon in nested form

断了今生、忘了曾经 提交于 2019-12-08 04:06:05
问题 In my application in Rails 4, I use Cocoon to have nested forms. It works well in the browser, but I want to add some tests with rspec. If I make a click_link("add") (or 'remove') in my test, rspec doesn't see any modification (I print page.body before and after). I also tried with a sleep(10) but it's the same. How could I test if the action (add or remove a nested form) works well ? Thanks EDIT: The scenario to test : scenario "nested form" do user_sign_in contact = FactoryGirl.create(

Rails Nested Forms Not Updating Nested Model

删除回忆录丶 提交于 2019-12-07 22:58:05
问题 I am having trouble trying to update nested models in my form. I don't get any errors and but the attributes don't get updated. I have the following model: class Trip < ActiveRecord::Base has_many :segments accepts_nested_attributes_for :segments, allow_destroy: true end class Segment < ActiveRecord::Base belongs_to :start_location, class_name: 'Location' belongs_to :end_location, class_name: 'Location' belongs_to :trip validates_presence_of :date, :start_location, :end_location end class

nested forms for 2 models in rails using dm-accepts_nested_attributes and dm-is-tree

依然范特西╮ 提交于 2019-12-07 20:10:58
问题 I have two models: Post and Image in a forum application where Posts are arranged in parent-child format using dm-is-tree. Up this point, the images had been part of the Post model. As the Post model gets unwieldy and I need to add more depth to notating the image, I'm working to spin off the Image into its own model, but is still part of the post in output. So I started integrating dm-accepts_nested_attributes in a simple arrangement: class Post include DataMapper::Resource property :id,

Multilevel Nested form not showing in Active Admin

时光总嘲笑我的痴心妄想 提交于 2019-12-07 19:36:29
问题 I'm trying to Implement a multilevel Nested form. These are my models workout.rb has_many :workout_weeks accepts_nested_attributes_for :workout_weeks workout_week.rb belongs_to :workout has_many :workout_days accepts_nested_attributes_for :workout_days workout_day.rb belongs_to :workout_week and my workout edit part in active admin is like form do |f| inputs 'Workout Details' do f.input :workout_name f.inputs do f.has_many :workout_weeks, heading: 'Workout Week', allow_destroy: true do |ww|

Rails 4: Multiple image upload using paperclip

夙愿已清 提交于 2019-12-07 18:35:46
问题 I'm looking to upload multiple images to my 'locations' model. I've called the images model 'assets'. One location has multiple assets. I'm also using paperclip to handle the uploads and nested_form to allow selecting multiple assets. Weirdly, the locations hash looks to be passing the variables correctly, but they don't appear to be being picked up by the assets model. Any help would be great! Location model class Location < ActiveRecord::Base has_many :location_post has_many :posts,

Access object value within accepts_nested_attributes_for form

ε祈祈猫儿з 提交于 2019-12-07 10:17:10
问题 I have the following setup: class Option < ActiveRecord::Base has_many :size_prices accepts_nested_attributes_for :size_prices end def new @option = Option.new @sizes = @customization.item.sizes @sizes.each do |size| @option.size_prices.build({:size_id => size.id}) end end <%= f.fields_for :size_prices do |price_form| %> I would like to do something like: <%= Size.find(price_form.size_id).name %> <%= price_form.text_field :amount %> <% end %> Is there any way to access the size_id's of each