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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:34:40+00:00 2026-06-15T23:34:40+00:00

I keep getting this strange error, even though everything works on localhost. 1) User

  • 0

I keep getting this strange error, even though everything works on localhost.

  1) User pages profile page 
     Failure/Error: before { visit user_path(user) }
     ActionView::Template::Error:
       undefined method `model_name' for NilClass:Class
     # ./app/views/shared/_create_list.html.erb:2:in `_app_views_shared__create_list_html_erb__3760252191913263716_70266394394440'
     # ./app/views/users/show.html.erb:17:in `_app_views_users_show_html_erb__4038196524711190952_70266368588040'
     # ./spec/requests/user_pages_spec.rb:12:in `block (3 levels) in <top (required)>'

users_controller

class UsersController < ApplicationController
  before_filter :signed_in_user, only: [:edit, :update]
  before_filter :correct_user,   only: [:edit, :update]

  def show
    @user = User.find(params[:id])
    @lists = @user.lists
    @list = current_user.lists.build if signed_in?
  end

lists_controller

class ListsController < ApplicationController
  before_filter :signed_in_user

  def create
    @list = current_user.lists.build(params[:list])
    if @list.save
      flash[:success] = "List created!"
      redirect_to current_user
    else
      redirect_to current_user
    end
  end

_create_list partial

<div class="white-box">
<%= form_for(@list) do |f| %>
  <%= render 'shared/error_messages', object: f.object %>
  <div class="field">
    <%= f.text_field :name, placeholder: "Create new list..." %>
    <%= f.submit "Create list", class: "btn btn-primary" %>
  </div>
<% end %>
</div>

users/show

  <div class="span8">
    <% if @user.lists.any? %>
      <h3>Lists (<%= @user.lists.count %>)</h3>
      <ol class="lists">
        <%= render @lists %>
      </ol>
    <% end %>
    <%= render 'shared/create_list' %>
  </div>

user_pages_spec

require 'spec_helper'

describe "User pages" do

  subject { page }

  describe "profile page" do
    let(:user) { FactoryGirl.create(:user) }
    let!(:m1) { FactoryGirl.create(:list, user: user, name: "Foo") }
    let!(:m2) { FactoryGirl.create(:list, user: user, name: "Bar") }

    before { visit user_path(user) }

I am very new to rails and this error has been haunting me for days! Any suggestions are much appreciated!

  • 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-15T23:34:41+00:00Added an answer on June 15, 2026 at 11:34 pm

    This problem is because you assign object to @list if the User is login, otherwise it will be nil only.

    To resolve the issue add the condition if @list in (users/show)

    <%= render 'shared/create_list' if @list %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to install pear package and keep getting this strange error. Can you shed
I keep getting this strange error when I use capybara methods outside of a
I keep getting this error on asp.net page button click...how do i resolve this?
I keep getting this error and i have been trying everything for about a
Keep getting this error after inserting a subdatasheet into a query and trying to
I keep getting this error and have no idea why. I googled and scanned
I keep getting this error on emulator: I copied this from a tutorial and
I keep getting this error Error in readPNG(destfile) : libpng error: PLTE: CRC error
I keep getting this error with my Play 2.0 application: play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[MatchError:
I keep getting this stored procedure error (wrong number or types of the arguments)

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.