Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fields.nested_form[:update_only] should always be false by default. #2626

Closed
antoine-lizee opened this issue Apr 29, 2016 · 3 comments · Fixed by #3649
Closed

fields.nested_form[:update_only] should always be false by default. #2626

antoine-lizee opened this issue Apr 29, 2016 · 3 comments · Fixed by #3649

Comments

@antoine-lizee
Copy link

See the "first bug" in this stack overflow answer.

It's a personal opinion, but I think that interpreting accept_nested_attributes_for: ..., update_only:true as "disable the form when creating the object" is a potential misunderstanding of the option, (for Rails 4), and should at least be documented in the wiki?

@ericcf
Copy link

ericcf commented May 3, 2016

@antoine-lizee as a first step, I've created a gist to reproduce the issue here: https://gist.github.com/ericcf/f4da02ca5bb80d889131f603448ee10c

There is a difference between update_only: true and update_only: false, which seems like a bug to me as well based on the description in the Rails documentation. In my example, accepts_nested_attributes_for :dog, update_only: false leads to being able to add a Dog record upon creation of a Person, which seems to be correct.

@sferik is this interpretation correct? Would you like a failing spec for this case or is more discussion necessary? Thanks.

@GProst
Copy link

GProst commented Jul 6, 2020

We're having the same issues because of the misunderstanding of this option by Rails Admin. It's unexpected that you can't create a new association for a model when update_only is set to true for accept_nested_attributes_for

@myers
Copy link
Contributor

myers commented Oct 6, 2023

BTW, if you do the following:

RailsAdmin.config do |config|
  config.model 'User' do
    base do
      configure :location do
        nested_form[:update_only] = false
      end
    end
  end
end

In order to get Rails Admin to show the child form when creating a instance, you will actually change the settings on the model as nested_form returns the same hash used to configure the model.

You should do this instead:

      configure :location do
        nested_form(nested_form.clone)
        nested_form[:update_only] = false
      end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants