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 7942893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:06:41+00:00 2026-06-04T00:06:41+00:00

I’m trying to create an index page where all assets are displayed including a

  • 0

I’m trying to create an index page where all assets are displayed including a link to the user who they are assigned to, however when I use

def index
 @assets = Asset.paginate(page: params[:page])
 @user = User.find(params[:id])
end

It returns – couldn’t find User without an ID.

index.html.erb – Assets

<%= provide(:title, 'Assets') %>
<h1>All assets</h1>
<%= will_paginate @assets %>
<ol class="assets">
    <%= render @assets %>
</ol>
<%= will_paginate @assets %>

_asset.html.erb partial

<li>
<span class="id">JTC<%= asset.id %></span>
<span class="serial"><%= asset.serial_no %></span>
<span class="status">Status: <%= asset.status %></span>
<span class="type">Type: <%= asset.asset_type %><br/></span>
<span class="description">Description: <%= asset.asset_description %><br /></span>
<span class="comment"><em><%= asset.comment %></em></span>
<span class="timestamp">
    <br />Added <%= time_ago_in_words(asset.created_at) %> ago. <br /> Assigned to: <%= link_to 
    @user.name %>
    <br />Date Purchased: <%= asset.date_purchased %> 
</span>
</li>
  • 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-04T00:06:43+00:00Added an answer on June 4, 2026 at 12:06 am

    @user = User.find(params[:id]) is expecting a URL along the lines of /assets/40, where 40 is the id (and even then that wouldn’t make sense, since the 40 should be the id of the asset, not the user). When you just access /assets, there is no id parameter, so it tries to basically do User.find(nil), which gives you that error.

    Assuming assets belong to users, you should just get rid of the @user = User.find(params[:id]) line in your controller, and change your partial to use asset.user.name instead of @user.name.

    To avoid an N+1 query situation on your users, you could update your controller to use this:

    @assets = Asset.includes(:user).paginate(page: params[:page])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I need to clean up various Word 'smart' characters in user input, including but
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters 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.