Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8062653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:44:29+00:00 2026-06-05T10:44:29+00:00

I am struggling to pass an id successfully into my URL for the nested

  • 0

I am struggling to pass an id successfully into my URL for the nested resource I have set up called Jobs.

The error I am getting when I try to pass the @job object into my link is as follows:

  No route matches {:action=>"edit", :controller=>"jobs", :user_id=>1, :id=>nil}

Which clearly shows it can’t find the id correctly and so is finding nil

At the moment I have my routes setup as so:

 resources :users do
   resources :jobs
 end

and the link I have is <%= link_to "Edit", edit_user_job_path(@user.id,@job) %>

What is interesting is that if I pass the object @jobs with an ‘s’ on the end it will load the page correctly but when I click on the link will try and add all of that users job id’s.

In my controller for edit I have:

def edit
 @user = current_user
 @job = @user.jobs.find(params[:id])
end

Any help really would be much appreciated 🙂

UPDATE

Okay I was defining the object on the wrong page of my controller (under edit instead of index). The issue I am now having is Couldn't find Job without an ID

I updated my controller index definition to:

 def index
  @user = current_user
  @jobs = @user.jobs.all
  @job = @user.jobs.find(params[:id])
 end

And have in my view (jobs#index)

<% @jobs.each do |f| %>
 ...
 <%= link_to "Edit", edit_user_job_path(@user.id,job) %>
 ...
<% end %>

Any advice would be much appreciated if you know where I am going wrong 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:44:30+00:00Added an answer on June 5, 2026 at 10:44 am

    That error means that @job is nil.

    The link is to the edit path, and the controller code you’ve provided is from the edit action in the controller. It seems unlikely that the edit page links to itself.

    Look at the code that’s actually rendering that page (it will appear in your stack trace) and you’ll find that @job is not set. I suspect that you are on the index page and have something like:

    <% @jobs.each do |job| %>
      ...
      <%= link_to "Edit", edit_user_job_path(@user.id,@job) %>
      ...
    <% end %>
    

    If that is the case, then the link should be to job, not @job, i.e.

    <%= link_to "Edit", edit_user_job_path(@user.id,job) %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been struggling with this for days. This works, but does not pass
I just finished this script it works well, but I am struggling to pass
I'm writing a simple test program to pass multidimensional arrays. I've been struggling to
Struggling with styling the mouse over for a button ... I have managed to
Im struggling with this one. I have a list of items and on a
Iam struggling with NHibernate and its lazyload. I have a structure which I simplified
I have been struggling with a unit testing problem on Android for a while
I have a function that (via ajax) I pass a Guid and a comma
I use playframework, and I am struggling with a concurrent task: I have a
I'm struggling myself here, to find a easy way to pass an array from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.