I want to call a method of one controller in another controller's method, and also pass parameters like below:
Controller A:
@var
def methodA
update(@var)
end
Controller B:
def update(var)
var1 = var
end
Is there any way to do this?
I want to call a method of one controller in another controller's method, and also pass parameters like below:
Controller A:
@var
def methodA
update(@var)
end
Controller B:
def update(var)
var1 = var
end
Is there any way to do this?
Why not define the shared method in ApplicationController
instead and call it in both controllers as they each inherit it's methods. Like so:
ApplicationController:
class ApplicationController < ActionController::Base
protected
def update(var)
var1 = var
end
end
Other Controllers:
class SomeController < ApplicationController
def some_method()
@var = 'something'
update(@var)
end
end
class SomeOtherController < ApplicationController
def some_method()
@var = 'something'
update(@var)
end
end