Skip to content

Instantly share code, notes, and snippets.

@d-shimizu
Last active September 21, 2018 02:57
Show Gist options
  • Save d-shimizu/6567961 to your computer and use it in GitHub Desktop.
Save d-shimizu/6567961 to your computer and use it in GitHub Desktop.
Railsでのモジュールのオートロード ref: http://qiita.com/d_shimizu/items/4affe530d541db56e937
module TestApp
class Application < Rails::Application
### モジュール自動ロードPathの指定を追記
config.autoload_paths += %W(#{config.root}/lib)
end
end
class TestController < ApplicationController
### モジュールの読み込み(インクルード)
include Hoge
def index
### indexメソッド内でHogeモジュールの「test_module_method」メソッドを実行
test_module_method
end
end
module Hoge
def test_module_method
処理内容
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment