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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:17:07+00:00 2026-06-04T16:17:07+00:00

This CURD generated by scaffold method using following command rails g scaffold contact fullname:string

  • 0

This CURD generated by scaffold method using following command

rails g scaffold contact fullname:string surname:string email:string mobile:string note:text

when i go to localhost:3003/contacts/new getting following error

    NoMethodError in Contacts#new

Showing /root/contactlist/app/views/contacts/_form.html.erb where line #16 raised:

undefined method `fullname' for #<Contact:0xb2fa75b4>

Extracted source (around line #16):

13: 
14:   <div class="field">
15:     <%= f.label :fullname %><br />
16:     <%= f.text_field :fullname %>
17:   </div>
18:   <div class="field">
19:     <%= f.label :surname %><br />

Trace of template inclusion: app/views/contacts/new.html.erb

Rails.root: /root/contactlist
Application Trace | Framework Trace | Full Trace

app/views/contacts/_form.html.erb:16:in `_app_views_contacts__form_html_erb___387033993__645411558'
app/views/contacts/_form.html.erb:1:in `_app_views_contacts__form_html_erb___387033993__645411558'
app/views/contacts/new.html.erb:3:in `_app_views_contacts_new_html_erb__1061805842__644918458'
app/controllers/contacts_controller.rb:29:in `new'

This is my views/contacts/_form.html.erb

    <%= form_for(@contact) do |f| %>
  <% if @contact.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@contact.errors.count, "error") %> prohibited this contact from being saved:</h2>

      <ul>
      <% @contact.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :fullname %><br />
    <%= f.text_field :fullname %>
  </div>
  <div class="field">
    <%= f.label :surname %><br />
    <%= f.text_field :surname %>
  </div>
  <div class="field">
    <%= f.label :email %><br />
    <%= f.text_field :email %>
  </div>
  <div class="field">
    <%= f.label :mobile %><br />
    <%= f.text_field :mobile %>
  </div>
  <div class="field">
    <%= f.label :note %><br />
    <%= f.text_area :note %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

this is the Controller file “contacts_controller.rb”

 class ContactsController < ApplicationController
      # GET /contacts
      # GET /contacts.json
      def index
        @contacts = Contact.all

        respond_to do |format|
          format.html # index.html.erb
          format.json { render :json => @contacts }
        end
      end

      # GET /contacts/1
      # GET /contacts/1.json
      def show
        @contact = Contact.find(params[:id])

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

      # GET /contacts/new
      # GET /contacts/new.json
      def new
        @contact = Contact.new

        respond_to do |format|
          format.html # new.html.erb
          format.json { render :json => @contact }
        end
      end

      # GET /contacts/1/edit
      def edit
        @contact = Contact.find(params[:id])
      end

      # POST /contacts
      # POST /contacts.json
      def create
        @contact = Contact.new(params[:contact])

        respond_to do |format|
          if @contact.save
            format.html { redirect_to @contact, :notice => 'Contact was successfully created.' }
            format.json { render :json => @contact, :status => :created, :location => @contact }
          else
            format.html { render :action => "new" }
            format.json { render :json => @contact.errors, :status => :unprocessable_entity }
          end
        end
      end

      # PUT /contacts/1
      # PUT /contacts/1.json
      def update
        @contact = Contact.find(params[:id])

        respond_to do |format|
          if @contact.update_attributes(params[:contact])
            format.html { redirect_to @contact, :notice => 'Contact was successfully updated.' }
            format.json { head :no_content }
          else
            format.html { render :action => "edit" }
            format.json { render :json => @contact.errors, :status => :unprocessable_entity }
          end
        end
      end

  # DELETE /contacts/1
  # DELETE /contacts/1.json
  def destroy
    @contact = Contact.find(params[:id])
    @contact.destroy

    respond_to do |format|
      format.html { redirect_to contacts_url }
      format.json { head :no_content }
    end
  end
end

This is the Model file “contact.rb”

class Contact < ActiveRecord::Base
  attr_accessible :email, :fullname, :mobile, :note, :surname
end

Please help me solve this error i’m stuck.

  • 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-04T16:17:08+00:00Added an answer on June 4, 2026 at 4:17 pm

    Everything looks right. Run rake db:migrate then restart the server.

    Edit:

    if you have created the table already and you want to recreate it then drop the old table first

    Add this to the top of the migration

    def change
      drop_table contacts
      .... #create the new contact table
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is an example of the code am using. I use a modified version
This question is quite specific. I'm using Symfony2 White October Admin Bundle for generating
This question is related to hooking with Mobile Substrate, but as long as you
This is my first day coding and using jquery, I figured the best way
This is my first time using Magento. I upgraded this site from 1.4.1.1 to
this is what i have so far: type u = {str : string} //some
This doesn't seem to work (=null): @Resource(name = java:app/AppName) private String appName; But a
This is really just for my own use: I would like to be able
This somehow simple task is not so simple. I can get the number of
This has been a rather problematic issue on numerous occasions. We have alot of

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.