0

For the jobs -> apply action I want to "alias" the "create" action.

In rake routes it would look something like this:

https://gist.github.com/YOUConsulting/19b404759757898a6f4f#file-rake_routes-rb

I've tried to do it like this but I think this is not exactly what I'm looking for:

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

In human words:

When the user submits the page located at "/jobs/<job_id_here>/apply" (the index view) the result page (the create view) should be "/jobs/<job_id_here>/apply/completed" instead of "/jobs/<job_id_here>/apply/" .

Reason:

When we track users via Google Analytics we can't see if they submitted the form successfully since there is no difference between "/apply" and "/apply" .

1 Answer 1

1

Hm, what about using a named route as path

Add a line at the end of your routes.rb

post '/jobs/:job_id/apply/completed', to: apply#create as: apply_job

And then in your new.html.haml

form_for :job, apply_job_path

This should call the create action of your apply controller.

Instead of apply you can use of course any name you want.

1
  • Thanks you are freaking awesome! :) Jan 23, 2015 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.