# How to change a scope of the accessor in model?

**URL:** <https://www.ruby-forum.com/t/how-to-change-a-scope-of-the-accessor-in-model/117422>\
**Category:** Rails\
**Created:** [October 16, 2007, 7:02pm UTC](https://www.ruby-forum.com/t/how-to-change-a-scope-of-the-accessor-in-model/117422 "2007-10-16T19:02:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikolay\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f9ae1b/32.png) [@Nikolay\_P](https://www.ruby-forum.com/u/Nikolay_P)\
**Post date:** [October 16, 2007, 7:02pm UTC](https://www.ruby-forum.com/t/how-to-change-a-scope-of-the-accessor-in-model/117422/1 "2007-10-16T19:02:18Z")

</div>

Hello all.  
I have a table “Account” with the “value” column.  
How i can change a scope for it, so that is will be only accessable in a  
Account class? I’ve tried to overload a method, but no luck:

> > class Account \< ActiveRecord::Base  
> > private  
> > def value=(amount)  
> > write\_attribute(:value, amount)  
> > end  
> > end  
> > =\> nil
> 
> > ll = Account.new  
> > =\> #\<Account:0xb6ef598c @new\_record=true,  
> > @attributes={“name”=\>nil, “entity\_id”=\>nil, “updated\_at”=\>nil,  
> > “currency\_id”=\>nil, “account\_group\_id”=\>nil,  
> > “value”=\>#\<BigDecimal:b6eafb6c,‘0.0’,4  
> > (12)\>, “base\_value”=\>#\<BigDecimal:b6eafa18,‘0.0’,4  
> > (12)\>, “account\_num”=\>nil, “created\_at”=\>nil}\>
> 
> > ll.private\_methods.include? “value=”  
> > =\> true
> 
> > ll.value = 10  
> > =\> 10
> 
> > ll.value  
> > =\> #BigDecimal:b718d064,‘0.1E2’,4(8)
> 
> >

# –

- Best regards, Nikolay P… \<\<\<-----------------------------------  
======================================================================
