teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

補足を追記

2019/12/15 07:07

投稿

siruku6
siruku6

スコア1382

answer CHANGED
@@ -38,6 +38,7 @@
38
38
 
39
39
  こうすると、redirect_to の行以外全てを、 model メソッドまたはcontrollerの privateメソッドへと移行可能です
40
40
 
41
+ ※modelメソッドへ移行する場合の記載例になります
41
42
  ```ruby
42
43
  def methodEx(params)
43
44
  destination_path = モデル名.hoge_method(params)

1

誤記修正

2019/12/15 07:07

投稿

siruku6
siruku6

スコア1382

answer CHANGED
@@ -40,12 +40,12 @@
40
40
 
41
41
  ```ruby
42
42
  def methodEx(params)
43
- destination_path = hoge_method(params)
43
+ destination_path = モデル名.hoge_method(params)
44
44
  redirect_to destination_path
45
45
  end
46
46
 
47
47
  # model 又は controller の praivate 以下
48
- def hoge_method(params)
48
+ def self.hoge_method(params)
49
49
  case params
50
50
  when A
51
51
  #処理1行