I have a view which is not updatable one, so I have created a rule after getting the below error
ActiveRecord::StatementInvalid: PG::ObjectNotInPrerequisiteState: ERROR: cannot delete from view "<view_name>"
DETAIL: Views containing GROUP BY are not automatically updatable.
HINT: To enable deleting from the view, provide an INSTEAD OF DELETE trigger or an unconditional ON DELETE DO INSTEAD rule.
This is the rule i have created
CREATE RULE <view_name_del> AS ON DELETE TO <view_name>
DO INSTEAD
DELETE FROM <view_name>
WHERE xyz = OLD.xyz;
But it has generated another error, Not sure how to correct it
Caused by PG::InvalidObjectDefinition: ERROR: infinite recursion detected in rules for relation "view_name"