I added two fields to my devise user. I did this by adding them at the migrate file like this:
t.datetime :access_bought_at, :default => DateTime.civil(0, 0, 0, 0, 0, 0, 0)
t.string :access_type, :default => "none"
and then making those attributes accessible at the user model:
attr_accessible :email, :password, :password_confirmation, :remember_me, :access_type, :access_bought_at
Then made the migration (rake db:migrate).
But I’m having trouble accessing these fields and modifying them. I’m pretty new to rails, and I’m pretty sure the answer is pretty straightforward, but I cannot find (or understand what I find) about how to access and modify those field. This is what I’m trying to do. In certain controller I want to modify those fields, and I’m doing:
current_user::access_type = "forever"
current_user::access_bought_at = Date.current()
but then, if I make
puts current_user::email
puts current_user::access_type
puts current_user::access_bought_at
only the email get’s printed out. I’m guessing that I’m missing either missing a step and I’m not updating the database, or I’m doing it just plain wrong. I read here ( update a table which in not devise model on sign up using devise?) that I should just put a def in the model. A def how? It makes sense that since I change the model I should give instructions about how to modify it, so adding a method to do that seems right, but what should that method do?
devise user model still have activerecord api like any other model