LoginSignup
11
10

More than 1 year has passed since last update.

routes.rb でnew アクションに複数ステップ持たせたい時はnew methodでDRYする。

Last updated at Posted at 2013-09-10

例えばオーダーをnewする際に複数ステップにわけたい時に(Wizard形式っていうんですね)

GET  /order/new/step1
POST /order/new/step1
POST /order/new/step2
POST /order/new/step3
POST /order/new/confirm

としたい場合に

resources :orders, only: [:create, :show] do
  new do
    match 'step1', via: [:get, :post]
    post 'step2'
    post 'step3'
    post 'confirm'
  end
end

とすることでURLを作成できる。

11
10
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
10