title: Ruby on Rails change background colour in CSS according to database
body: <p>In my Ruby on Rails application I am trying to allow the user to choose their colour and have this as the sites background.</p>
  
  <p>In my schema I have this preferences table:</p>
  
  <pre><code>create_table "perferences", force: :cascade do |t|
    t.integer  "user_id"
    t.integer  "category_id"
    t.datetime "created_at",  null: false
    t.datetime "updated_at",  null: false
    t.text     "colour"
  end
  </code></pre>
  
  <p>The CSS background colour is in the following line:</p>
  
  <pre><code>body{line-height:1;height:100%;width:100%;color:#B2BFCB;background:#002952;text-align:center;font-family:"Apercu Regular", Calibri, sans-serif;font-weight:normal;font-style:normal;margin:0;padding:0;}
  </code></pre>
  
  <p>But I am unsure as to how to update the colour based upon the colour in the database.</p>
  
  <p>I have tried to follow this link: <a href="http://blog.hasmanythrough.com/2007/10/18/simpler-than-dirt-restful-dynamic-css" rel="nofollow">http://blog.hasmanythrough.com/2007/10/18/simpler-than-dirt-restful-dynamic-css</a>
  But I got the error: <code>undefined method formatted_colour_path for #&lt;#&lt;Class:0x6daa0a8&gt;:0x6881b98&gt;</code></p>
  
  <p>In the view:</p>
  
     
  
  <p>In the perferences controller:</p>
  
  <pre><code>def show
     @colour = Perference.find_by(user_id: session[:user_id]).colour
     respond_to do |format|
          format.html
          format.css
     end
  end
  </code></pre>
  
  <p>Can someone please help. I understand that I need to retrieve the colour from the database and then use this to update the CSS, but I am not sure how to do this.</p>