routingの設定で少し悩んだのでメモ
# apps/web/config/routes.rb
get '/', to: 'home#index'
get '/show', to: 'home#show'
このようにroutingに記述した場合、1画面ごとに対応するファイルを作った。
個人的に、これファイル多すぎと感じたので下記のように記述したところ動作した。
before
- apps/web/controllers/home/index.rb
module Web::Controllers::Home
class Index
include Web::Action
def call(params)
end
end
end
- apps/web/controllers/home/show.rb
module Web::Controllers::Home
class Show
include Web::Action
def call(params)
end
end
end
- apps/web/views/home/index.rb
module Web::Views::Home
class Index
include Web::View
end
end
- apps/web/views/home/show.rb
module Web::Views::Home
class Show
include Web::View
end
end
- apps/web/templates/home/index.html.erb
- apps/web/templates/home/show.html.erb
after
- apps/web/controllers/home/index.rb
module Web::Controllers::Home
class Index
include Web::Action
def call(params)
end
end
class Show
include Web::Action
def call(params)
end
end
end
- apps/web/views/home/index.rb
module Web::Views::Home
class Index
include Web::View
end
class Show
include Web::View
end
end
- apps/web/templates/home/index.html.erb
- apps/web/templates/home/show.html.erb
あんましっくりきてないけどとりあえずはこれで行こうと思う。
もっといい書き方あったら教えてください。