Joã*_*nha 1 ruby model ruby-on-rails plural
我有这个模型
class Oferta < ActiveRecord::Base
belongs_to :entidade
has_many :candidatos, :through => :interesses
has_many :interesses, foreign_key: "oferta_id", dependent: :destroy
Run Code Online (Sandbox Code Playgroud)
基本上我有这个模型和模型Interesse及其复数,interesses但我认为Rails实际上是es在最后取消 并留给我Interess.现在它给了我这个错误:
uninitialized constant Oferta::Interess
Run Code Online (Sandbox Code Playgroud)
我如何定义的单数interesses是interesse?并不是interess
Ser*_*yol 10
你可以在你的config/initializers/inflections.rb文件中做这样的事情.
ActiveSupport::Inflector.inflections do |inflect|
inflect.irregular 'interesse', 'interesses'
end
Run Code Online (Sandbox Code Playgroud)