Last active
September 21, 2018 02:57
-
-
Save d-shimizu/6583365 to your computer and use it in GitHub Desktop.
Rails4におけるController,Modleのモジュールのロード ref: http://qiita.com/d_shimizu/items/7e57e7eb62e0d96f9b0b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Hoge | |
def hoge_module_method | |
処理内容 | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestController < ApplicationController | |
### モジュールの読み込み(インクルード) | |
include Hoge | |
… | |
def index | |
… | |
### indexメソッド内でHogeモジュールの「hoge_module_method」メソッドを呼び出す | |
hoge_module_method | |
… | |
end | |
… | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment