railsのコントローラーのアクションのインスタンス変数を、別のActionでもつかいたいのですが、どうしたらいいのでしょうか?
たとえば、以下の例で言うと、loginメソッドを実行した際の帰り値となる、「@login_driver」をautoexhibitメソッドに渡し、libで定義しているOtAutoExhibitクラスの、a_hoge_exhibitメソッドで使いたいです。
class UsersController < ApplicationController def index end def login ec = OtLogin.new @login_result, @login_driver = ec.hoge_login(login_params) end def autoexhibit(@login_driver) otamart = OtAutoExhibit.new @auto_exhibit_result = otamart.a_hoge_exhibit(@login_driver) end
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/10/15 13:19
2018/10/15 23:30
2018/10/17 11:19