-1

I have this model:

   class User < ActiveRecord::Base
     attr_accessible :subscription_process

     def self.prepare_user
          user = User.new
          user.subscription_process = true
          user.save
     end
   end

Inn the email that is send to the user - I use devise I have subscription_process that is equal to true. I want to know if subscription_process is saved somewhere?

Tsvetelina Borisova
  • 417
  • 1
  • 4
  • 14

2 Answers2

1

Don't confuse attr_accessor and attr_accessible - those are two completely different things.

As for the question, the value is stored in the database.

user.subscription_process = true
user.save # here, it gets saved.
Sergio Tulentsev
  • 226,338
  • 43
  • 373
  • 367
0

When you say obj.save then the it would be inserted in database and the values would be hold in that object. In your case when you save it, it will insert in Users table in database and the values are available in user object with id.

To understand attr_accessible and attr_accessor please go through this link: Difference between attr_accessor and attr_accessible

Hope this helps !!!

Community
  • 1
  • 1
Anand Soni
  • 5,070
  • 11
  • 50
  • 101