Note that there are some explanatory texts on larger screens.

plurals
  1. POundefined method `first_name'
    primarykey
    data
    text
    <p>Can anyone shed light on this for me? </p> <p>undefined method `first_name' for #</p> <p>Here is the show.html</p> <pre><code>&lt;p id="notice"&gt;&lt;%= notice %&gt;&lt;/p&gt; &lt;div id="container"&gt; &lt;p&gt; &lt;b&gt;First name:&lt;/b&gt; &lt;%= @artist.firstname %&gt; &lt;/p&gt; &lt;p&gt; &lt;b&gt;Second name:&lt;/b&gt; &lt;%= @artist.surname %&gt; &lt;/p&gt; &lt;p&gt; &lt;b&gt;About:&lt;/b&gt; &lt;%= @artist.about %&gt; &lt;/p&gt; &lt;div id="comments"&gt; &lt;h2&gt;Comments&lt;/h2&gt; &lt;%= render :partial =&gt; "shared/comment", :collection =&gt; @artist.comments%&gt; &lt;/div &lt;/div&gt; &lt;%= render :partial =&gt; "image", :collection =&gt; @artist.images %&gt; &lt;%= link_to 'Edit', edit_artist_path(@artist) %&gt; | &lt;%= link_to 'Back', artists_path %&gt; &lt;%= link_to 'show', images_path %&gt; </code></pre> <p>Here is the partial </p> <pre><code> &lt;div class="comment"&gt; &lt;p&gt; &lt;span class="commentator"&gt;&lt;%= comment.commentator.display_name %&gt; say's&lt;/span&gt; &lt;%= comment.comment %&gt; &lt;/p&gt; &lt;/div </code></pre> <p>Here is the friend view </p> <pre><code>class Friends &lt; ActiveRecord::Base attr_accessible :firstname, :surname has_many :comments, :as =&gt; :commentator, :class_name =&gt;"Commentable" def display_name "#{self.firstname} #{self.surname}" end end </code></pre> <p>This is the friends controller</p> <pre><code>class FriendsController &lt; ApplicationController # GET /friends # GET /friends.xml def index @friends = Friend.all respond_to do |format| format.html # index.html.erb format.xml { render :xml =&gt; @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 =&gt; @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 =&gt; @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 =&gt; 'Friend was successfully created.') } format.xml { render :xml =&gt; @friend, :status =&gt; :created, :location =&gt; @friend } else format.html { render :action =&gt; "new" } format.xml { render :xml =&gt; @friend.errors, :status =&gt; :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 =&gt; 'Friend was successfully updated.') } format.xml { head :ok } else format.html { render :action =&gt; "edit" } format.xml { render :xml =&gt; @friend.errors, :status =&gt; :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 </code></pre> <p>I am trying to make it so a friend can leave a comment on an artists page but I keep getting the above error. </p> <p>I am very new to Ruby so I apologise if I have left anything out.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload