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

Association model errors on not reflecting on form object #2

Open
Dhamsoft opened this issue Apr 2, 2018 · 1 comment
Open

Association model errors on not reflecting on form object #2

Dhamsoft opened this issue Apr 2, 2018 · 1 comment

Comments

@Dhamsoft
Copy link
Contributor

Dhamsoft commented Apr 2, 2018

Data Setup

    Customer.delete_all
    House.delete_all
    @vendor = Customer.create!(name: "Test User", email: "[email protected]", phone_number: "123-4567")
    @house = House.create!(:vendor => @vendor, :street_number => "8/90", :street_name => "Main Street", :city => "Townsville")
    @rooms = [
      @house.house_rooms.create!(:name => "Bedroom", :area => 20),
      @house.house_rooms.create!(:name => "Bathroom", :area => 16),
    ]
    @room_listing_form = RoomListingForm.new(@house)

Code for reproducing the case

   @room_listing_form.update!(:city => "Fancyville", :rooms_attributes => { @rooms.first.id.to_s => { "id" => @rooms.first.id.to_s, "room_name" => "", :area => 9 }}) recue ActiveRecord::RecordInvalid

   @room_listing_form.valid? # true
   @room_listing_form.rooms.first.valid? # false
   @room_listing_form.errors.full_messages # []
   @room_listing_form.rooms.first.errors.full_messages # ["Room name can't be blank"]
@Dhamsoft
Copy link
Contributor Author

Dhamsoft commented Apr 2, 2018

Test coverage added #3

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

1 participant