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

Mongoid embedded document boolean selector does not work #3554

Open
rpalackas opened this issue Oct 3, 2022 · 3 comments
Open

Mongoid embedded document boolean selector does not work #3554

rpalackas opened this issue Oct 3, 2022 · 3 comments

Comments

@rpalackas
Copy link
Contributor

Describe the bug
When a mongoid document has an embedded class the boolean selector doesn't work on new or edit

Reproduction steps
Create mongoid class with embedded document
Embedded document needs to have a Mongoid::Boolean field
Add the embedded document in accepts_nested_attributes_for
Open edit or create for the parent document in rails admin
Clicking any of the buttons for the boolean won't change your selection

Expected behavior
Clicking the buttons will change the selection

Additional context
Digging into the html it seems to be that the label field has an incorrect for value:
What rails admin creates:

<input class="btn-check" type="radio" value="1" name="parent_class[embedded_class_attributes][field_name]" id="parent_class_embedded_class_attributes_field_name_1">
<label for="parent_class[embedded_class_attributes]_field_name_1" class="success btn btn-outline-success">
<span class="fas fa-check"></span>
</label>

What it should be:

<input class="btn-check" type="radio" value="1" name="parent_class[embedded_class_attributes][field_name]" id="parent_class_embedded_class_attributes_field_name_1">
<label for="parent_class_embedded_class_attributes_field_name_1" class="success btn btn-outline-success">
<span class="fas fa-check"></span>
</label>

manually updating that label tag for attribute via admin tools fixes the problem.

  • rails version: 6.1.6.1
  • rails_admin version: 3.0.0
  • mongoid version: 7.5.1
@rpalackas
Copy link
Contributor Author

rpalackas commented Oct 4, 2022

I've resolved the issue locally and created a PR with my fix here: #3555 I know your contributions page requests specs for the issue however I followed the contributions guide to setup and run specs locally and they're all failing with:

An error occurred while loading ./spec/integration/fields/wysihtml5_spec.rb. - Did you mean?
                    rspec ./spec/integration/fields/time_spec.rb
                    rspec ./spec/integration/fields/enum_spec.rb
                    rspec ./spec/integration/fields/simple_mde_spec.rb

Failure/Error: require 'sprockets/railtie'

LoadError:
  cannot load such file -- sprockets/railtie
# ./spec/dummy_app/config/application.rb:22:in `require'
# ./spec/dummy_app/config/application.rb:22:in `<top (required)>'
# ./spec/dummy_app/config/environment.rb:4:in `require'
# ./spec/dummy_app/config/environment.rb:4:in `<top (required)>'
# ./spec/spec_helper.rb:30:in `require'
# ./spec/spec_helper.rb:30:in `<top (required)>'
# ./spec/integration/fields/wysihtml5_spec.rb:3:in `require'
# ./spec/integration/fields/wysihtml5_spec.rb:3:in `<top (required)>'
/Users/richardpalackas/rails_admin/spec/spec_helper.rb:5: warning: already initialized constant CI_ORM
/Users/richardpalackas/rails_admin/spec/spec_helper.rb:5: warning: previous definition of CI_ORM was here
/Users/richardpalackas/rails_admin/spec/spec_helper.rb:6: warning: already initialized constant CI_TARGET_ORMS
/Users/richardpalackas/rails_admin/spec/spec_helper.rb:6: warning: previous definition of CI_TARGET_ORMS was here
/Users/richardpalackas/rails_admin/spec/spec_helper.rb:7: warning: already initialized constant PK_COLUMN
/Users/richardpalackas/rails_admin/spec/spec_helper.rb:7: warning: previous definition of PK_COLUMN was here

feel free to update the PR to meet your requirements

@mshibuya
Copy link
Member

Please refer to CONTRIBUTING.md, which got updated recently.

@rpalackas
Copy link
Contributor Author

Sorry it's been so long since I updated this. Finally had some time to work on the specs

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

No branches or pull requests

2 participants