2012-03-16 62 views
1

任何人都可以向我建议如何定义自定义模型名称。当我尝试生成名称为3AForm的模型时,它提出了一个错误。在导轨中定义自定义模型名称

rails g model 3A_Form date_of_investigation:date date_of_transcription:date by:string     investigator:string type_of_investigative_activity:text results_of_investigation:text 

回答

4

这是行不通的,3A_Form在Ruby中不是一个有效的类名。也许你应该尝试rails g model Form3A ...。如果你需要你的模型与一个陌生的名字连接到现有的表,那么你可以在你的类中使用table_name

class Form3A < ActiveRecord::Base 
    self.table_name = 'your_weird_table_name' 
    #... 
end 
+0

感谢您的帮助。 – 2012-03-16 06:52:19