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

The Archive Base Latest Questions

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

Can anyone shed light on this for me? undefined method `first_name’ for # Here

  • 0

Can anyone shed light on this for me?

undefined method `first_name’ for #

Here is the show.html

<p id="notice"><%= notice %></p>
<div id="container">
<p>
  <b>First name:</b>
  <%= @artist.firstname %>
</p>

<p>
  <b>Second name:</b>
  <%= @artist.surname %>
</p>

<p>
  <b>About:</b>
  <%= @artist.about %>
</p>
<div id="comments">

  <h2>Comments</h2>

<%= render :partial => "shared/comment", :collection => @artist.comments%>

</div
</div>

<%= render :partial => "image", :collection => @artist.images %>
<%= link_to 'Edit', edit_artist_path(@artist) %> |
<%= link_to 'Back', artists_path %>
<%= link_to 'show', images_path %>

Here is the partial

 <div class="comment">



     <p>


      <span class="commentator"><%= comment.commentator.display_name %> 

    say's</span>


      <%= comment.comment %>


      </p>



    </div

Here is the friend view

class Friends < ActiveRecord::Base
    attr_accessible :firstname, :surname
    has_many :comments, :as => :commentator, :class_name =>"Commentable"
    def display_name
    "#{self.firstname} #{self.surname}"
    end


end

This is the friends controller

class FriendsController < ApplicationController
  # GET /friends
  # GET /friends.xml
  def index
    @friends = Friend.all

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

  # GET /friends/1
  # GET /friends/1.xml
  def show
    @friend = Friend.find(params[:id])

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

  # GET /friends/new
  # GET /friends/new.xml
  def new
    @friend = Friend.new

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

  # GET /friends/1/edit
  def edit
    @friend = Friend.find(params[:id])
  end

  # POST /friends
  # POST /friends.xml
  def create
    @friend = Friend.new(params[:friend])

    respond_to do |format|
      if @friend.save
        format.html { redirect_to(@friend, :notice => 'Friend was successfully created.') }
        format.xml  { render :xml => @friend, :status => :created, :location => @friend }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @friend.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /friends/1
  # PUT /friends/1.xml
  def update
    @friend = Friend.find(params[:id])

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

  # DELETE /friends/1
  # DELETE /friends/1.xml
  def destroy
    @friend = Friend.find(params[:id])
    @friend.destroy

    respond_to do |format|
      format.html { redirect_to(friends_url) }
      format.xml  { head :ok }
    end
  end
end

I am trying to make it so a friend can leave a comment on an artists page but I keep getting the above error.

I am very new to Ruby so I apologise if I have left anything out.

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

    Basically, rails will look at the database to figure out what fields are on a model. So make sure your migrations have been run, and that first_name exists on the db table.

    Also, Friends is plural. In rails, your table is plural (friends), your model is singular (Friend), and your controller is plural (FriendsController). It is best not to go against this convention. Try renaming the model and see what happens

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

Sidebar

Related Questions

Can anyone shed some light on this for me: http://67.212.188.229/fcf/index.html <- Please look at
Hope anyone can shed light on this so I can use pens with dash
Can anyone shed any light on this? I feel like I have wasted the
Can anyone shed some light on this? From Bison's documentation, I didn't see anything
Can anyone shed some insight onto why the following happens? irb(main):001:0> r = '1'..'30'
How do I place the shortcut icon in the cab file? Can anyone shed
Can anyone offered syntax for a sql query that takes an already created table
Can anyone direct me to a good tutorial for sqlite browser. I cant seem
Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
Can anyone tell me how I can display a status message like 12 seconds

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.