So I have a module "MiddleMan" I am able to call it just fine in the rails console but in the controller I am getting a NoMethodError
In the controller I have:
class SignUpController < ApplicationController
include MiddleMan
def page_one
@package = MiddleMan::read_catalog("a", "b", "c")
end
end
And in the middleman.rb module I have:
module MiddleMan
def read_catalog(package, payment, coupon)
Package.new(:price => "4.99")
end
end
Any thoughts?
Since you included the module the instance method read_catalog
is added to your Class, so you can call it directly:
class SignUpController < ApplicationController
include MiddleMan
def page_one
@package = read_catalog("a", "b", "c")
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With