Reputation: 7409
I got this error
NoMethodError (undefined method `get_routes' for
How could I access get_routes
from Sample.run
module FlightUtil
extend ActiveSupport::Concern
def get_routes(from="TAIPEI", to="OSAKA")
~~~
end
class Sample
def run
get_routes("A", "B")
end
end
end
Upvotes: 1
Views: 22
Reputation: 4980
You need to include the module FlightUtil in the Sample class.
module FlightUtil
extend ActiveSupport::Concern
def get_routes(from="TAIPEI", to="OSAKA")
~~~
end
class Sample
include FlightUtil
def run
get_routes("A", "B")
end
end
end
A Module is a collection of methods and constants. Classes nested inside of modules are used to namespace the classes. You have to include a module in order to access the module's contents (methods or constants).
Upvotes: 1