2013-10-16 34 views

回答

1

您必須覆蓋activerecord的model.rb文件。它看起來像這樣:

<% module_namespacing do -%> 
class <%= class_name %> < <%= parent_class_name.classify %> 
<% attributes.select(&:reference?).each do |attribute| -%> 
    belongs_to :<%= attribute.name %><%= ', polymorphic: true' if attribute.polymorphic? %> 
<% end -%> 
<% if attributes.any?(&:password_digest?) -%> 
    has_secure_password 
<% end -%> 
end 
<% end -%> 

把它放在lib文件夾:

|____lib 
| |____templates 
| | |____active_record 
| | | |____model 
| | | | |____model.rb 
相關問題