title: How do I return an array of attributes defined via a Rails model method, as well as the attributes in the database table?
body: <p>I have a Rails model called Person which has database table columns for first_name and last_name. I've also defined a full_name method to return the combined first_name and last_name of the instance. </p>
  
  <p>Is there a way to return an array, hash, or object which has first_name, last_name, as well as full_name?</p>
  
  <p>Here's the code I have:</p>
  
  <pre><code>#person.rb
  class Person &lt; ActiveRecord::Base
    validates_presence_of :first_name, :last_name  
  
    def full_name
          self.first_name + " " + self.last_name
    end
  end
  </code></pre>
  
  <p>Here's what I've tried in the Rails console:</p>
  
  <pre><code>ruby-1.8.7-p302 &gt; person = Person.new({:first_name=&gt;"Bruce", :last_name=&gt;"Wayne"})
   =&gt; #&lt;Person id: nil, first_name: "Bruce", :last_name: "Wayne", created_at: nil, updated_at: nil&gt; 
  
  ruby-1.8.7-p302 &gt; person.save!
   =&gt; true 
  
  ruby-1.8.7-p302 &gt; Person.last
   =&gt; #&lt;Person id: 1, first_name: "Bruce", :last_name: "Wayne", created_at: "2010-11-09 22:53:14", updated_at: "2010-11-09 22:53:14"&gt; 
  </code></pre>
  
  <p>Is it possible to get something returned like this instead:</p>
  
  <pre><code>ruby-1.8.7-p302 &gt; Person.last
   =&gt; #&lt;Person id: 1, first_name: "Bruce", :last_name: "Wayne", :full_name: "Bruce Wayne", created_at: "2010-11-09 22:53:14", updated_at: "2010-11-09 22:53:14"&gt; 
  </code></pre>
  
  <p>Or can it only return values from the database?</p>
  
  <p>Eventually, I'd like to be able to call <code>Person.all</code> to return an array of hashes which also includes full_name.</p>
  
  <p>Thanks in advanced!</p>