Choosing a second entry in the rails console?

I need to select the second entry in the user model.

User.second does not work, as well as User.2 or User.two .

I am trying to set u to the second user entry ( u = User.2 )

+4
source share
1 answer

The following should work:

 User.all.second User.offset(1).first # Assuming you are using incremental keys and have users with ID 1 and 2: User.find(2) 
+6
source

Source: https://habr.com/ru/post/1497631/


All Articles