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

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -