As per rails guides says ActiveRecord::AssociationTypeMismatch should be raised only when there is association mismatch but in my case its something new..
Below is exception :
ActiveRecord::AssociationTypeMismatch (Service(#50963840) expected, got Service(#70493480)):
Parameters trace:
Parameters: {"utf8"=>"✓", "authenticity_token"=>"EyilRRem8MLjCrIGq5aovntlrWpCnVBbq/v0tO1HpD4=", "room"=>{"name"=>"room1", "service_ids"=>["2", "3", "4"], "location_id"=>"25", "capacity"=>"2"}, "multiselect_room_service_ids"=>"4", "commit"=>"Update Room", "id"=>"3"}
Creating scope :page. Overwriting existing method AdminUser.page.
AdminUser Load (0.2ms) SELECT `admin_users`.* FROM `admin_users` WHERE `admin_users`.`id` = 1 LIMIT 1
Room Load (0.2ms) SELECT `rooms`.* FROM `rooms` WHERE `rooms`.`id` = 3 LIMIT 1
Service Load (0.2ms) SELECT `services`.* FROM `services` WHERE `services`.`id` IN (2, 3, 4)
Service Load (0.1ms) SELECT `services`.* FROM `services` INNER JOIN `service_rooms` ON `services`.`id` = `service_rooms`.`service_id` WHERE `service_rooms`.`room_id` = 3 AND (is_active IS true)
(0.1ms) BEGIN
Creating scope :page. Overwriting existing method Service.page.
Creating scope :page. Overwriting existing method Category.page.
(0.1ms) ROLLBACK
Completed 500 Internal Server Error in 79ms
ActiveRecord::AssociationTypeMismatch (Service(#50963840) expected, got Service(#70493480)):
Can somebody explain what could be the possible issue ??
It was my mistake .. i was referring service association which wasn’t actually service object 🙂