Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd custom column to User Model using rails Clearance gem
    primarykey
    data
    text
    <p>I use the Clearance gem to add authentification to my website. The standard User model looks like this:</p> <pre><code>class User &lt; ActiveRecord::Base include Clearance::User end </code></pre> <p>Now i want to add more properties to the User Model. I created this migration:</p> <pre><code>class AddCustomernameToUsers &lt; ActiveRecord::Migration def change add_column :users, :customername, :string end end </code></pre> <p>After rake db:migrate, the database now has one more column for :customername</p> <p>as next step I edited the User Model file so it looks like this:</p> <pre><code>class User &lt; ActiveRecord::Base include Clearance::User attr_accessor :customername end </code></pre> <p>As the next step, I signed up a new user and used sqlite database browser to add the test string 'charly' in the customer name field for this user.</p> <p>In my controller, i now want to create a user object and print it out to see if all the data is present.</p> <pre><code>thisUser = User.find(current_user.id) puts thisUser.inspect </code></pre> <p>the console output is:</p> <pre><code>#&lt;User id: 1, email: "test@test.de", encrypted_password: "0494a9b3b692acaea96ab57bed500adf26dbafa5", salt: "75c889d099438476204ce46b9cb406fb1f73423c", confirmation_token: nil, remember_token: "907b9bd600246d0b8dcc06a782457665f614b368", created_at: "2012-03-21 20:59:44", updated_at: "2012-03-21 21:12:59", customername: nil&gt; </code></pre> <p>so customername is nil. somehow the data for this field is not pulled out of the database correctly.</p> <p>what am i doing wrong?</p> <p>Sorry, I'm a rails beginner. Might be a very simple thing to do, but I tried hard and googled all day and couldn't get it to work, so I turn to the wisdom of stack overflow. Thanks guys.</p>
    singulars
    1. This table or related slice is empty.
    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