RoR:我有两个非常相似的控制器,并且想要超类/子类化它们



但是我想知道这个的命名约定是什么?

像. .我有object和template_object

所以,object自然是超类,template_object是子类。

文件夹和东西的命名约定是什么?object_template_object吗?idk =

在我打破每一个标准之前,我只是在寻找任何可以遵循的指导方针。div =

你已经有了一个超类控制器的例子——ApplicationController。它的名字没有约定,应该以Controller结尾

命名约定仅前缀命名空间:

class ApplicationController < ActionController::Base
end #=> url_for(:controller => 'application') == application_url()
class UsersController < ApplicationController
end #=> url_for(:controller => 'users') == users_url()
module ProfileSide
  class SomeController < ApplicationController
  end #=> url_for(:controller => 'profile_side/some_controller') 
      #    == profile_side_some_url() 
  class OtherController < SomeController
  end #=> url_for(:controller => 'profile_side/other_controller')
      #    == profile_side_other_url()
end 

最新更新