我的名字中有点表,无法查询。我的表名是:site.com_news
在模型中,根据How do I explicitly specify a Model's table-name mapping in Rails?我设置:
class News < ActiveRecord::Base
self.table_name = "site.com_news"
end
在日志中:
E, [2014-10-06T17:22:34.119037 #15975] ERROR -- : Mysql2::Error: Table 'site.com_news' doesn't exist: SELECT `site`.`com_news`.* FROM `site`.`com_news`
I, [2014-10-06T17:22:34.150211 #15975] INFO -- : Rendered news/index.html.erb within layouts/application (36.2ms)
I, [2014-10-06T17:22:34.150696 #15975] INFO -- : Completed 500 Internal Server Error in 65ms
F, [2014-10-06T17:22:34.155848 #15975] FATAL -- :
ActionView::Template::Error (Mysql2::Error: Table 'site.com_news' doesn't exist: SELECT `site`.`com_news`.* FROM `site`.`com_news`):
如何在表名中转义点字符?我尝试“site.com_news
” - 不起作用。
根据http://dev.mysql.com/doc/refman/5.0/en/identifiers.html: 数据库和表名称不能包含“/”,“\”,“。”或文件名中不允许的字符。
谢谢 但在PHP中,这种结构是有效的:(