I have a table called User_Roles in my sqlite3 database. Using the Ruby on Rails console I’ve tried the following:
UserRoles.firstUser_Roles.firstuserroles.firstUser_Role.firstuser_roles.firstUserRole.firstUser_Role.firstuserrole.first
What am I typing incorrect just to get the first row in the User_Roles table?
Thanks
I would guess UserRole.first
It should be whatever the name of the corresponding model class is. It’s odd that the table name is capitalized. Normally, this is what you’d expect, having generated the migration using something like
rails generate model UserRole:table name:
user_rolesmodel file:
app/models/user_role.rbmodel name:
UserRole(defined in user_role.rb)If the naming of all of these things doesn’t jive together, then strange (or more likely just wrong) things may happen.