Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Have you add <code>has_many :awards</code> to the <code>User</code> model? Have you added <code>belongs_to :user</code> to the <code>Award</code> model? Have you added the column <code>user_id</code> to the <code>Award</code> model (using a migration)? You'll need to do these three things to be able to use the <code>user.awards</code> method you're using. Read the <a href="http://www.google.com.au/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;ved=0CFUQFjAA&amp;url=http://guides.rubyonrails.org/association_basics.html&amp;ei=RWjmT9mME429iAertYRZ&amp;usg=AFQjCNEiaqyRhMemV_2s_ZqwjTaYdA42bQ&amp;sig2=1XnJTum0xuhqfgrEgwu2_A" rel="nofollow">Rails Guide on Associations</a> for more detail.</p> <p>Also, <code>append</code> isn't a Ruby method - the closest method would be <code>&lt;&lt;</code>. You would use it like this: </p> <pre><code>a = Award.new(:name =&gt; "Nobody Award", :description =&gt; "From Jonathan", :category =&gt; "Community", :value =&gt; 1337, :level =&gt; 0, :handle =&gt; "nobody_award") user.awards &lt;&lt; a </code></pre> <p>But you could neaten this into one line of code using the <code>create</code> method:</p> <pre><code>a = user.awards.create(:name =&gt; "Nobody Award", :description =&gt; "From Jonathan", :category =&gt; "Community", :value =&gt; 1337, :level =&gt; 0, :handle =&gt; "nobody_award") </code></pre> <p>EDIT: To create the <code>user_id</code> column in the <code>Award</code> model, run the following code from terminal (while in your app's directory):</p> <pre><code>rails generate migration AddUserIdToAward user_id:integer rake db:migrate </code></pre>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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