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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:40:01+00:00 2026-06-06T02:40:01+00:00

I am just beginning to work with Rails. I have a model, User and

  • 0

I am just beginning to work with Rails. I have a model, “User” and it has many “List”. On the user show view I have created a form to create a list for the current user. When the form is submitted I get the following error:

Couldn’t find User without an ID

I assume that there is something wrong with the way I have setup the nested List form.

User -> show.html.erb

    <p id="notice"><%= notice %></p>

<p>
  <b>Username:</b>
  <%= @user.username %>
</p>

<p>
  <b>Password:</b>
  <%= @user.password %>
</p>

<p>
  <b>Email:</b>
  <%= @user.email %>
</p>

<h2>Add a List</h2>
 <%= form_for([@user, @user.lists.build]) do |f| %>
 <div class ="field">
    <%= f.label :title %><br />
    <%= f.text_field :title %>
</div>
<div class="field">
    <%=f.label :description%><br />
    <%=f.text_field :description%>
</div>
<div class="actions">
    <%= f.submit %>
</div>

<% end %>



<%= link_to 'Edit User', edit_user_path(@user) %> |
<%= link_to 'Back to Users', users_path %>

This is the list ‘create’ controller action.

 class ListsController < ApplicationController
    def create
        @user = User.find(params[:id])
        @list = @user.lists.create(params[:list])
        redirect_to user_path(@user)        
    end
end

Update: show method on UserController

 # GET /users/1
  # GET /users/1.json
  def show
    @user = User.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @user }
    end
  end

Update: My routes

    resources :users do
      resources :lists
  end

  get "home/index"

So is params[:id] nil somehow? What am I missing?

Thanks!

  • 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-06T02:40:02+00:00Added an answer on June 6, 2026 at 2:40 am

    Make sure you are using params[:user_id] in create action, not params[:id]

    class ListsController < ApplicationController
        def create
            @user = User.find(params[:user_id]) 
            @list = @user.lists.create(params[:list])
            redirect_to user_path(@user)        
        end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just beginning design work on a problem that I'm sure has been
I am just beginning to work on android and seems like I have got
I'm just beginning to have a look at Objective-C and Cocoa with a view
I am just beginning to get into desktop application development, and have chosen C#
I am implementing a user based reccomender that should work just on categories of
I'm just beginning to work with bash scripts and I've tried to get a
I am beginning work on a large Visual Studio solution, and have come across
I'm just beginning to wet my feet with KnockoutJS. So far, I have the
I'm beginning to work on a new Ruby on Rails application that is a
I'm just beginning a project where my system (written in .NET MVC) will have

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.