activerecord - Limit the number of records in table in Rails -


I want to keep a table in the rail, to limit the number of records. If I have a notification table, So how can I work to keep only 50 records at a time? Therefore, if any new record is added then first is removed and new one is saved as 50th.

Is there a good rail system to do it automatically or do I have to implement it manually? When I am creating a new information?

I think it is very easy to implement itself. / P>

1 liner

  notification. First.destroy if notification count & gt; 50   

Use it in first / create> callback

Comments

Popular posts from this blog

Out of index C/C++ -

regex - PatternSyntaxException: while using String.ReplaceAll function in java? -

objective c - how Set autolayout for multiple dynamic buttons and labells in iOS? -