We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I have vehicle has many vehicle_services relation. I am trying to insert vehicle_services via accepts_nested_attributes_for method.
Vehicle.rb
class Vehicle < ActiveRecord::Base has_many :vehicle_services accepts_nested_attributes_for :vehicle_services, :reject_if => lambda { |service| service[:service_on].blank? }
If I try to save vehicle with not valid vehicle_services params I do not get information about which child relation did cause error(s).
Method:
vehicle_params = {"licence_plate"=>"PO-XYZ", "vehicle_services_attributes"=> {"0"=>{"service_on"=>"2015-11-11"}, "1"=>{"service_on"=>"SHOULD_RAISE_ERROR-not-correct-date"} ...} vehicle = Vehicle.create(vehicle_p) puts vehicle.errors.to_json
Outputs:
{"vehicle_services.service_on":["wrong date format"]}
In vehicle variable I didn't get any information about which vehicle_service is causing errors. Was it index 0 or 1? I would expect errors like:
{"vehicle_services.1.service_on":["wrong date format"]}
The text was updated successfully, but these errors were encountered:
This is a dup of #8638
Sorry, something went wrong.
No branches or pull requests
I have vehicle has many vehicle_services relation. I am trying to insert vehicle_services via accepts_nested_attributes_for method.
Vehicle.rb
If I try to save vehicle with not valid vehicle_services params I do not get information about which child relation did cause error(s).
Method:
Outputs:
In vehicle variable I didn't get any information about which vehicle_service is causing errors. Was it index 0 or 1? I would expect errors like:
The text was updated successfully, but these errors were encountered: