mercredi 13 mai 2015

Add URL parameters on successful create method

Case:

When I submit my form that is located on /jobs/test-lune-f/apply?locale=fr the create method gets launched and does some checks.

The code will either run trough the whole create method and go the the create.html.erb page or will do return render :index.

Problem:

The problem is that the create.html.erb has the same URL /jobs/test-lune-f/apply?locale=fr as the index.html.erb page.

Question:

When the create method runs completely ok, is it possible to an URL parameter like #success to it?

I've tried to do this via the addition of :anchor => "success" to the form_for but it also get's added when the method returns via return render :index.

Goal:

To be able to add URL parameters when the form get's submitted successfully.

CODE:

Routes:

  resources :jobs, :only => [:show, :index, :create] do
    resources :apply, :only => [:index, :create]
    resources :share, :only => [:index, :create]
  end

  resources :apply, :only => :index do
    collection { get 'add'}
  end

Aucun commentaire:

Enregistrer un commentaire