Virtual attributes in Rails

What do you knew about virtual attriburtes in rails ? Generally we can
get
idea about attr_accessible and attr_accessor

so what these two can do . i found the difference between these two from
this blog. Very useful plz check it
Virtual attributes in Rails | MyWayOnRailshttp://mywayonrails.wordpress.com/2013/04/01/virtual-attributes-in-rails/

Thanks

Sriram

sree ilapakurthy wrote in post #1108220:

What do you knew about virtual attriburtes in rails ? Generally we can
get
idea about attr_accessible and attr_accessor

so what these two can do . i found the difference between these two from
this blog. Very useful plz check it

Virtual attributes in Rails | MyWayOnRailshttp://mywayonrails.wordpress.com/2013/04/01/virtual-attributes-in-rails/

The first thing you should know is that attar_accessible will be removed
from Rails 4 to be replaced by strong parameters.

See here for more:

The attar_accessor is really nothing more than a declarative statement
for specifying getters and setters for instance variable (which is
really all that virtual attributes are). In anything other than
ActiveRecord models “virtual attributes” are called “instance
variables.” Sometimes these are also called “transient variables”
because they are attributes that are to be excluded from persistence
either in a serialized format or persistent storage (database). Some
languages have specific syntax for transient variables although AFAIK
Ruby does not.

Example:

attr_accessible :name

is essentially equivalent to

def name
@name
end

def name=(name)
@name = name
end