Your code is simply deleting the item, with no impact on the feed. I think you need to either:
- Explicitly clear the
item_type
anditem_id
references infeed
(e.g. by implementing aremove_item
method in your Feed controller and model), or - If your domain would allow for it, change your
belongs_to
association to ahas_one
association, with corresponding changes to your database. In that case, deleting the item wouldn't require any changes to the associated feed.
As an aside, it's unusual to keep your migration in with your model definition. The migration should really be in a separate file.