Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Removing Records
2 Posts
Removing Records

I'm assuming your talking about removing records from an activerecord Model and its associated table. I highly recommend NOT deleting actual records but instead 'soft-deleting' them. I think this is usually the smart way to go, in case you need to refer to those records that you had previously deleted later on.

The way I have usually done this is by adding a 'deleted' field to the concerning model via a migration. This deleted field is a boolean and it's default value is false. Then when you want to delete a record you'd actually do a 'soft-delete' and just go ahead and mark true for the deleted field for the repective record.

You would also want to make sure that you are NOT using records marked 'deleted' in parts of your application where it won't make sense. For instance, a regular user should NOT be able to see posts that have been marked as deleted.

Hope this helps

How do I go about removing company/project records?

2 Posts
Login to add your message