Ruby on Rails 3을 사용하고 있으며 네임 스페이스를 사용하여 모듈을 구현하려고합니다. 내 lib/
폴더에서네임 스페이스를 사용하여 모듈 구현하기
나는이에서와 authorization.rb
파일이 : 내 컨트롤러에서
module Authorizations
def Authorizations.message
return "flash_message"
end
end
내가 가진 :
class Users::AccountsController < ApplicationController # 'Users' is the namespace
include Authorizations
def create
...
flash.now[:notice] = Authorizations.message
end
end
나는 create
방법을 실행하면 나는이 오류가 발생합니다 :
NoMethodError (undefined method 'message' for Authorizations:Module)
wro 응?
모듈 문에서 나는 이러한
def Authorizations::message
...
# or
def message
...
도 그 작동하지 않습니다를 tryed.
나를 위해 작동하지 않습니다. 어쨌든 당신은 더 명확 할 수 있습니까? 어쩌면 그 이유는 ... – user502052