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

  • Home
  • SEARCH
  • 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 6242381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:56:37+00:00 2026-05-24T11:56:37+00:00

When I try to go to the localhost:3000/items/new link it says their is an

  • 0

When I try to go to the localhost:3000/items/new link it says their is an uninitialized constant error in ItemsController::Item. I’m not sure what the problem is.

my Application.html.erb layout looks like

<!DOCTYPE html>
<html>
<head>
<title>TestApp</title>
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
<%= javascript_include_tag "prototype", "effects" %>
<%= csrf_meta_tag %>
</head>
<body>
<%= @content_for_layout %>
<%= yield %>

</body>
</html>

new.html.erb view

<div id="show_item"></div>

<%= form_remote_tag :url => { :action, :create }, 
:update => "show_item", 
:complete => visual_effect(:highlight, "show_item") %>

Name: <%= text_field "item", "name" %><br />
Value: <%= text_field "item", "value" %><br />
<%= submit_tag %>
<%= end_form_tag %>

show.html.erb view

Your most recently created item: <br />
Name: <%= @item.name %><br />
Value: <%= @item.value %><br />
<hr>

items_controller

class ItemsController < ApplicationController

  def new
    @item = Item.new
  end

  def create
    @item = Item.create(params[:item])
    if request.xml_http_request?
      render :action => 'show', :layout => false
    else
      redirect_to :action => 'edit', :id => @item.id
    end
  end

  def edit
    @item = Item.find(params[:id])

    if request.post?
      @item.update_attributes(params[:item])
      redirect_to :action => 'edit', :id => @item.id
    end
  end
end
  • 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-24T11:56:38+00:00Added an answer on May 24, 2026 at 11:56 am

    You need item.rb in your models folder:

    item.rb

    class Item < ActiveRecord::Base
    end
    

    With whatever validations you need in there if any.

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

Sidebar

Related Questions

When I try to go to this url: http://localhost:3000/lessons/18/pages , I get this error:
I'm trying to make a RESTful API with rails. When I try http://localhost:3000/api/v1/projects.json?token=kS8xi7YzaUDEmbmi9XL6 I
Try to see which cast is faster (not necessary better): new c++ case or
Not sure what this means and why... I got the undefined method error when
I keep getting the error not authorized whenever i try to visit: appname.herokuapp.com/admin_data I've
Using the sample app for rpx_now gem ( http://github.com/grosser/rpx_now_example ) on localhost:3000, I have
When I up some app on my machine at localhost:3000/somecontroller. Is possible to turn
I have a rails app that uses Devise for user auth. In localhost:3000 my
I created a new rails app (3.2.3, ruby 1.9) and try to start server.
I'm getting a error when I try to acces users#show page trough a named

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.