from Rails3 to Rails4, set_table_name, set_primary_key is deprecated.

访问量: 4523

RAILS3的两个方法在RAILS4 中用不了:  set_table_name, set_primary_key. 

we should use #table_name = instead of #set_table_name.   

otherwise you will get undefined method `set_primary_key' for #<Class:0x37132e0>

 class CmsClientPid < CmsActiveRecord
-  set_table_name "cms_client"
-  set_primary_key :pid
+  self.table_name = "cms_client"
+  self.primary_key = 'pid'

refer to: http://stackoverflow.com/questions/20386636/rails-set-primary-key-error

订阅/RSS Feed

Subscribe

分类/category