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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:44:12+00:00 2026-05-31T02:44:12+00:00

I have this strange error I don’t understand. I have a model User defined

  • 0

I have this strange error I don’t understand. I have a model User defined as:

class User < ActiveRecord::Base
validates_presence_of :name, :email

has_many :caves
end

And an associated model Cave defined as:

class Cave < ActiveRecord::Base
  belongs_to :user
end

On my user’s show method, I offer to create a new cave:

<%= form_for([@user, @user.caves.build]) do |f| %>
<div class="field">
  <%= f.label :name %><br />
  <%= f.text_field :name %>
</div>
<div class="actions">
  <%= f.submit %>
</div>

But when I display the page, I get the following error:

NameError in Users#show
Showing E:/Vinisync/app/views/users/show.html.erb where line #19 raised:

uninitialized constant User::Cafe

Extracted source (around line #19):
16: </p>
17: 
18: <h2>Add a Cave</h2>
19: <%= form_for([@user, @user.caves.build]) do |f| %>
20:   <div class="field">
21:     <%= f.label :name %><br />
22:     <%= f.text_field :name %>

I don’t know where the hell this ‘Cafe’ comes from, I don’t have this word anywhere in my code!
What I’ve noticed is that if I rename the associated in User.rb has has_many :cave instead of has_many :caves as currently (and change it in the form in the users’s show.html.erb, the page displays normally. But my relationshiop is one to many, so it should read as ‘caves’ in User, not ‘cave’. I believe I’ve read all related questions here on SO and elsewhere, but I none of the solutions seem to apply.

  • 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-05-31T02:44:13+00:00Added an answer on May 31, 2026 at 2:44 am

    Sounds like Rails doesn’t realize that the singular of Caves is Cave. You can set this up manually in config/initializers/inflections.rb:

    inflect.irregular 'cave', 'caves'
    

    Then it will try to find Cave instead of Cafe.

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

Sidebar

Related Questions

it is very strange, because this error doesn't happen all the time... I have
I have this strange call stack and I am stumped to understand why. It
i am having a strange problem, i have a static class like this public
I have a problem when I update an object. This is the model: class
I have this strange error in one of my rails 2.3.2 application. NoMethodError in
I have stumbled upon a strange behavior that I don't understand. I have to
I have this strange issue with my web app. You see, I'm using jQuery
This is a strange one... In a windows forms app (VB.NET/VS 2005) I have
Why this two functions have the strange behaviour of when I click on thead,
This a bit of strange one.... We have an internal web app that runs

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.