简体   繁体   中英

Get data from table in Rails

I have table with name f_t_tik ( has no 's' in the end of its name ). Can I get data from this table from Rails? With my knowlegde, I know when I write code like @data = FTTik.all I received the SQL query like SELECT * from f_t_tiks; . But I must not change the name of table from f_t_tik to f_t_tiks . Is there a solution to resolve my problem?

yes you can specify the name of a models table in the model.rb file in your case you would need to add:

self.table_name = "f_t_tik"

to the file models/f_t_tik.rb

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM