User model:
class User < ActiveRecord::Base
attr_accessor :name, :email
has_secure_password
validates :password, presence: true, length: { minimum: 6 }
end
The problem is, in the Rails console, the attributes name, email, password, password_confirmation don't show up.
I suspect the first two are caused due to setting attr_accessor :name, :email
and the latter two due to has_secure_password
But, when I call those attributes separately, they show up:
Loading development environment (Rails 4.2.0)
2.2.1 :001 > u = User.new(name: "asd", email: "aedede@aece.com", password: "qweasd", password_confirmation: "qweasd")
=> #<User id: nil, name: nil, email: nil, created_at: nil, updated_at: nil, password_digest: "$2a$10$a98/zxfH0zaT0Hh.xalVPOxwbJiXAkH17BiRg.sV4hw...">
2.2.1 :002 > u
=> #<User id: nil, name: nil, email: nil, created_at: nil, updated_at: nil, password_digest: "$2a$10$a98/zxfH0zaT0Hh.xalVPOxwbJiXAkH17BiRg.sV4hw...">
2.2.1 :003 > u.name
=> "asd"
2.2.1 :004 > u.email
=> "aedede@aece.com"
2.2.1 :005 > u.password
=> "qweasd"
2.2.1 :009 > u.save
(0.2ms) begin transaction
User Exists (0.2ms) SELECT 1 AS one FROM "users" WHERE LOWER("users"."email") = LOWER('aedede@aece.com') LIMIT 1
SQL (0.4ms) INSERT INTO "users" ("password_digest", "created_at", "updated_at") VALUES (?, ?, ?) [["password_digest", "$2a$10$a98/zxfH0zaT0Hh.xalVPOxwbJiXAkH17BiRg.sV4hwFXp2jUiTnm"], ["created_at", "2015-06-10 02:42:22.437148"], ["updated_at", "2015-06-10 02:42:22.437148"]]
(130.8ms) commit transaction
=> true
2.2.1 :010 > u
=> #<User id: 3, name: nil, email: nil, created_at: "2015-06-10 02:42:22", updated_at: "2015-06-10 02:42:22", password_digest: "$2a$10$a98/zxfH0zaT0Hh.xalVPOxwbJiXAkH17BiRg.sV4hw...">
2.2.1 :011 > u.name
=> "asd"
I've checked everything thoroughly and can't find what's causing this, any insights to what's actually happening under the hood would be deeply appreciated.