Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to access table from rails console if the table has _ in its name

I am trying to access all records of a table that has an underscore in its name. For example if I have table in my schema that is called trips I can do Trip.all in rails console. But what do I do if my table name contains an underscore (e.g. users_foods)

I tried the following options:

Users_food.all
User_food.all
User_foods.all 
etc.

All of the above did not work, any suggestions?

like image 219
Quantico Avatar asked Sep 17 '25 10:09

Quantico


1 Answers

Figured it out One can access the data with UserFood

like image 169
Quantico Avatar answered Sep 19 '25 04:09

Quantico