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_for validation does not work #504

Closed
yigitbacakoglu opened this issue Mar 13, 2013 · 2 comments
Closed

fields_for validation does not work #504

yigitbacakoglu opened this issue Mar 13, 2013 · 2 comments

Comments

@yigitbacakoglu
Copy link

Hi, i had issue when using fields_for with has_many relations
ex. fields_for :accounts
The gem was generating validation attributes but was not validating. In the rails.validations.js I realised that name.replace(..) under validatorsForm regex does not works properly.
It replaces
'setting[profile_attributes][emails_attributes][1][address]' string with
setting[profile_attributes][][1][address] which is supposed to be
setting[profile_attributes][emails_attributes][][address]
changing this line (https://github.com/bcardarella/client_side_validations/blob/3-2-stable/vendor/assets/javascripts/rails.validations.js?#L47)
name = name.replace(/_attributes\]\[\w+\]\[(\w+)\]/g, "_attributes][][$1]"); with
name = name.replace(/_attributes\]\[\d+\]/g, "_attributes][]"); (regex found at v3.1.1) solved my issue.

@bcardarella
Copy link
Contributor

What version of Rails are you using?

@yigitbacakoglu
Copy link
Author

rails : 3.2.13
ruby: 1.9.3p194

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