开发者

About using Rails online documentation

Hey guys I'm new to Rails I found this code in the default application_controller.rb which generate by rails generator

class ApplicationController < ActionController::Base
  protect_from_forgery
end

And then after I check the protect_from_forgery method in online documentation, I found it's in ActionController::RequestForgeryProtection module not the ActionController::Base

Could Anybody tell me why, and how to chec开发者_运维百科k the method I can use of ApplicationController class

Thanks


it's because the ActionController::Base incude ActionController::RequestForgeryProtection

You can see all module include in ActionController::Base : http://api.rubyonrails.org/classes/ActionController/Base.html


You can mixin functionality into your class by using modules. This is a feature of ruby inheritance.

So, if it is module you are using, you can require it and then include it to mixin the functionality provided by the module into your class.

More about mixins here: http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_modules.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜