1

routes.rb:

resources :jobs do
  resources :activitylogs
end

rake routes:

...
                     POST /jobs/:job_id/activitylogs(.:format)          {:controller=>"activitylogs", :action=>"create"}
new_job_activitylog  GET  /jobs/:job_id/activitylogs/new(.:format)      {:controller=>"activitylogs", :action=>"new"}
edit_job_activitylog GET  /jobs/:job_id/activitylogs/:id/edit(.:format) {:controller=>"activitylogs", :action=>"edit"}
...

How do I use the route new_job_activitylog?

Doing <%= new_job_activitylog %> gives undefined exception - so does using link_to which most of the examples I see are using.

2 Answers 2

4

Use

<%= new_job_activitylog_path %>

or

<%= new_job_activitylog_url %>

_path returns a relative path, while _url returns a complete url including http://domain.com if you've set it in your config.

Sign up to request clarification or add additional context in comments.

Comments

0

To use those route names, I just had to append _path to them.

So: new_job_activitylog is undefined, but new_job_activitylog_path is a method in the view that takes the job id as a parameter.

<%= link_to 'new', new_job_activitylog_path(:job_id => @job.id) %>

works!

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.