Adding member or alias to existing path in Rails 3
For the jobs -> apply action I want to "alias" the "create" action.
In rake routes it would look something like this:
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/" .
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" .
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.