I am using Ruby on Rails 3 and I am trying to implement a Module using namespaces.
In my lib/ folder I have the authorization.rb file with in this:
module Authorizations
def Authorizations.message
return "flash_message"
end
end
In my controller I have:
class Users::AccountsController < ApplicationController # 'Users' is the namespace
include Authorizations
def create
...
flash.now[:notice] = Authorizations.message
end
end
When I run the create method I get this error:
NoMethodError (undefined method 'message' for Authorizations:Module)
What is wrong?
In the module statement I also tryed these
def Authorizations::message
...
# or
def message
...
and also those don’t work.
The problem is in the
RAILS_ROOT/config/application.rb. Just load thelib/folder in this way: