There are some fields present in table which i don't want to be visible outside?
Like created_on, is_first etc. I want to set value of these fields by using callbacks with in model but not accessible for some one to set it.
There are some fields present in table which i don't want to be visible outside?
Like created_on, is_first etc. I want to set value of these fields by using callbacks with in model but not accessible for some one to set it.
The standard way to prevent mass-assignment on certain fields is attr_protected
and attr_accessible
:
http://api.rubyonrails.org/classes/ActiveModel/MassAssignmentSecurity/ClassMethods.html
In your case, you would have to add this line in your model:
attr_protected :created_on, :is_first
Even if you have a form with these fields, their values will be ignored, when used in a new/create call.
def is_new =(is_new)
raise 'is_new is immutable!'
end