E
E
eldar_web2015-05-21 14:53:39
Ruby on Rails
eldar_web, 2015-05-21 14:53:39

Displays an error when you take the last element (Table.last), when there is one record in the table, how to solve the problem?

I need to select the last record (Table.last), but when there is only one record in the table, an error is thrown.
I just need to select the last entry in the algorithm anyway. How to solve the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Vsk, 2015-05-21
@eldar_web

If you are talking about ActiveRecord, then there can be no error when calling the first, last, second, etc. methods. there can be no error in cases where the entries are 1, 2, 3, 16 or even 0.
Well, if you have some code, show the code. If there is an error - write what error.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question