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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:08:09+00:00 2026-06-03T07:08:09+00:00

Ive got a problem with my Rails app. When I try to create a

  • 0

Ive got a problem with my Rails app.

When I try to create a new client in my clients table im getting this error => undefined method model_name for NilClass:Class

It’s telling me the error is in my show view at line #2.

1: <%- model_class = @client.class -%>
2: <h1><%=t '.title', :default => model_class.model_name.human %></h1>
3: 
4: <p>
5:   <strong><%= model_class.human_attribute_name(:name) %>:</strong><br>

Heres my show view..

<%- model_class = @client.class -%>
<h1><%=t '.title', :default => model_class.model_name.human %></h1>

<p>
  <strong><%= model_class.human_attribute_name(:name) %>:</strong><br>
  <%= @client.name %>
</p>
<p>
  <strong><%= model_class.human_attribute_name(:detail) %>:</strong><br>
  <%= @client.detail %>
</p>
<p>
  <strong><%= model_class.human_attribute_name(:more_detail) %>:</strong><br>
  <%= @client.more_detail %>
</p>
<p>
  <strong><%= model_class.human_attribute_name(:more_details) %>:</strong><br>
  <%= @client.more_details %>
</p>

<div class="form-actions">
  <%= link_to t('.back', :default => t("helpers.links.back")),
              clients_path, :class => 'btn'  %>
  <%= link_to t('.edit', :default => t("helpers.links.edit")),
              edit_client_path(@client), :class => 'btn' %>
  <%= link_to t('.destroy', :default => t("helpers.links.destroy")),
              client_path(@client),
              :method => 'delete',
              :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')),
              :class => 'btn btn-danger' %>
</div>

Here’s my controller =>

class ClientsController < ApplicationController

  respond_to :html

  def index
    @clients = Client.all
    respond_with (@clients)
  end

  def new
    @clients = Client.new
    respond_with (@clients)
  end

  def create
    @clients = Client.new(params[:name])
    if @clients.save
      flash[:notice] = "Client successfully created"
    end
    respond_with(@clients)
  end

  def destroy
  @clients = Client.find(params[:id])
  @clients.destroy
  flash[:notice] = "Client has been removed."
  respond_with(@clients)
  end

end

I can’t see where the problem is?

Ive recently installed the rails-twitter-bootstrap gem but don’t think that would effect it much.

  • 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-03T07:08:10+00:00Added an answer on June 3, 2026 at 7:08 am

    You’re setting in your controller the value of @clients (with s at the end) and accessing in your view just the @client variable, i.e. without s. Fix this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a very strange problem. I've got a rails app in which I
Ive got this problem: Line 20 (LOOT_FromContainer(container) I need that to use as Invoke
I'm learning Rails, and got into a little problem. I'm writing dead simple app
I've got a rails 3.1 app deployed on Heroku Cedar. I'm having a problem
I've got silly magic problem in rails! So, I've created table with foreign key
I've got several rails 3.1 apps, and I'm having this problem in all of
Ive got the following problem. I have a model called user which has a
got a problem with dets:to_ets/2 Could somebody point me to an example online? Ive
I've got a problem with Apache2 on my Linux Debian server. When I try
I've got a problem with simulating in game's process this action: - mouse_down -

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.