class UsersController < ApplicationController
def create
# call the action do_something from ImagesController
# continue in the normal flow
end
end
class ImagesController < ApplicationController
def do_something
...
end
end
執行從另一個控制器的操作我想從UsersController
呼叫在ImagesController
行動do_something
但執行後,我想繼續的create
行動,很少正常流動問題:如何在不離開當前控制器
- 這是不好的做法?
- 我該怎麼做?我是否必須創建
ImagesController
的實例,然後調用該操作還是有其他方法?
是的,這是一個不好的做法。你應該找到另一種方式。 –