I need to maintain fixed number of records. While my method is going to insert a new record then the old record will be delete automatically if the number of records reached to max length.
Max_length = 4
def create
@students = Student.new(params[:student])
if @students.save
if Student.find(:all).length >= Max_length
@old_students = Student.first
@old_students.destroy
end
end
end
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment