开发者

RoR: I have two controllers that are fairly similar, and want to superclass / subclass them

开发者 https://www.devze.com 2023-03-27 07:35 出处:网络
But I\'m wondering what the naming conventions are for this? Like.. I have object and template_object so, naturally, object will be the super class, template_object the subclass.

But I'm wondering what the naming conventions are for this?

Like.. I have object and template_object

so, naturally, object will be the super class, template_object the subclass.

What are the n开发者_如何学编程aming conventions for folders and stuff? object_template_object? idk =\

Just looking for any sort of guidelines to follow, before I just break every standard ever. =\


You already have an example of superclass controller - ApplicationController. There is no convention on its name excerpt it should end with Controller.


The naming conventions only prefix namespaces:

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 
0

精彩评论

暂无评论...
验证码 换一张
取 消