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
http://mywayonrails.wordpress.com/2013/04/01/virtual-attributes-in-rails/#more-174.<http://mywayonrails.wordpress.com/2013/04/01/virtual-attributes-in-rails/>


Thanks

Sriram

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/BcA7M0V8zSQJ.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Robert Walker at May 8, 2013 at 2:27 pm

    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
    http://mywayonrails.wordpress.com/2013/04/01/virtual-attributes-in-rails/#more-174.<http://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:
    http://weblog.rubyonrails.org/2012/3/21/strong-parameters/

    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

    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedMay 8, '13 at 12:01p
activeMay 8, '13 at 2:27p
posts2
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Robert Walker: 1 post Sri ram: 1 post

People

Translate

site design / logo © 2022 Grokbase