attr_accessor

1 view
Skip to first unread message

Abder-Rahman Ali

unread,
Sep 22, 2010, 8:37:21 AM9/22/10
to rubyonra...@googlegroups.com
I'm looking at an example here:
http://stackoverflow.com/questions/1330273/how-to-calculate-difference-of-two-fields-on-form-submit-ruby-on-rails

And, came along this line in MyModel:

attr_accessor :start_amount, :end_amount

What is "attr_accessor"?

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

Tim Shaffer

unread,
Sep 22, 2010, 8:52:36 AM9/22/10
to Ruby on Rails: Talk
On Sep 22, 8:37 am, Abder-Rahman Ali <li...@ruby-forum.com> wrote:
> I'm looking at an example here:http://stackoverflow.com/questions/1330273/how-to-calculate-differenc...
>
> And, came along this line in MyModel:
>
> attr_accessor :start_amount, :end_amount
>
> What is "attr_accessor"?

This isn't a Rails specific question, as attr_accessor is built-in
Ruby functionality.

Perhaps you should take a look at a Ruby tutorial about classes:

http://juixe.com/techknow/index.php/2007/01/22/ruby-class-tutorial/

Colin Law

unread,
Sep 22, 2010, 8:57:37 AM9/22/10
to rubyonra...@googlegroups.com
On 22 September 2010 13:37, Abder-Rahman Ali <li...@ruby-forum.com> wrote:
> I'm looking at an example here:
> http://stackoverflow.com/questions/1330273/how-to-calculate-difference-of-two-fields-on-form-submit-ruby-on-rails
>
> And, came along this line in MyModel:
>
> attr_accessor :start_amount, :end_amount
>
> What is "attr_accessor"?

Can I ask how long you spent trying to answer this for yourself?
_Please_ do some basic Ruby tutorials and also get and read the
Pickaxe Ruby book. If you keep asking such basic questions here
people will eventually get tired of answering them, and when you
really need help with a tricky problem you will have used up all your
calling credit.

Colin

radhames brito

unread,
Sep 22, 2010, 9:29:58 AM9/22/10
to rubyonra...@googlegroups.com
on the comments example i gave you go to the article.rb there is an explanation

also look at this

http://railscasts.com/episodes/26-hackers-love-mass-assignment


you can mail me directly for simple questions like this at

rbr...@gmail.com

that way you wont use up all your "calling credit"

Abder-Rahman Ali

unread,
Sep 22, 2010, 10:11:42 AM9/22/10
to rubyonra...@googlegroups.com
Thanks all for your replies.

And, really appreciate it @radhames.

Marnen Laibow-Koser

unread,
Sep 22, 2010, 12:41:23 PM9/22/10
to rubyonra...@googlegroups.com
Abder-Rahman Ali wrote:
> I'm looking at an example here:
> http://stackoverflow.com/questions/1330273/how-to-calculate-difference-of-two-fields-on-form-submit-ruby-on-rails
>
> And, came along this line in MyModel:
>
> attr_accessor :start_amount, :end_amount
>
> What is "attr_accessor"?

It's a sign that you need to go learn Ruby. :)

>
> Thanks.

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

Abder-Rahman Ali

unread,
Sep 22, 2010, 12:47:55 PM9/22/10
to rubyonra...@googlegroups.com
Sure @Marnen :-)

Abder-Rahman Ali

unread,
Sep 22, 2010, 12:56:01 PM9/22/10
to rubyonra...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages