A
A
Anton2016-10-09 21:26:34
Ruby on Rails
Anton, 2016-10-09 21:26:34

How to add alternative action "create?

The alternative "new" action is added with the ":on" parameter, but what about the "create" action?
Should a single "create" action handle all of these alternate "new" actions?
For example, I want to implement three alternative "new" actions:

resources :offer, except: [:destroy] do
  get 'text', on: :new
  get 'image', on: :new
  get 'video', on: :new
end

And how to track them in the "create" action?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vsuhachev, 2016-10-10
@vsuhachev

Сделайте 3 контроллера, в каждом будет свой new и create

C
Chronic 86, 2016-10-10
@chronic86

class MyController < ApplicationController
  def new
   redirect_to action: 'create1'
  end

  def create1
  end
end

Ну а на какой экшен слать выбирайте через if или switch-case.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question