ActiveRecord模型名称的约定

at.*_*at. 2 ruby naming ruby-on-rails naming-conventions ruby-on-rails-3

Rails中模型的命名约定是什么?如果我的模型是关于飞行汽车,以下哪个类名最合适?

class FlyingCar < ActiveRecord::Base
  attr_accessible :model, :max_speed
end

class Flying_Car < ActiveRecord::Base
  attr_accessible :model, :max_speed
end

class Flying_car < ActiveRecord::Base
  attr_accessible :model, :max_speed
end
Run Code Online (Sandbox Code Playgroud)

Dou*_*g R 5

FlyingCar是Ruby惯例.当ActiveRecord试图发挥其魔力时,这变得更加重要.您可以通过多种方式覆盖此行为,但使用FlyingCar是ActiveRecord所期望的.