我有这个模型
class Oferta < ActiveRecord::Base
belongs_to :entidade
has_many :candidatos, :through => :interesses
has_many :interesses, foreign_key: "oferta_id", dependent: :destroy
基本上我有这个模型和模型 Interesse
及其复数 interesses
但我认为 Rails 实际上在最后取消了 es
把兴趣留给我。现在它给了我这个错误:
uninitialized constant Oferta::Interess
如何定义 interesses
的单数是 interesse
?而不是 interess
最佳答案
您可以在您的 config/initializers/inflections.rb
文件中执行类似的操作。
ActiveSupport::Inflector.inflections do |inflect|
inflect.irregular 'interesse', 'interesses'
end
关于ruby-on-rails - Ruby on Rails - 定义模型或表的复数名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25544568/