Skip to content

Association model errors on not reflecting on form object #2

@Dhamsoft

Description

@Dhamsoft

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"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions