Sorry im replying from i new phone and is 5:00 am where i live , i
should have waited until i get to my pc and drink some coffe

2010/9/23, Michael Pavling <[email protected]>:
> On 23 September 2010 10:47, radhames brito <[email protected]>
> topposted again without any sign of trimming:
>> The function should bbe
>>
>> Def quantity_sold
>> Delivered_item + item_price
>> End
>>
>
> If you're going to write example code, please take the time to make
> sure it might even work... you should be aware of the case-sensitivity
> of Ruby.
> What on earth does "item_price" have to do with quantity sold? Where
> has the OP mentioned that? And infact, where has "Delivered_item" come
> from? Can I just check that you replied to the right message?
>
>> Then call quantity_sold.
>
> The OP has stated he wants to store the quantity_sold in the DB - how
> will this method help achieve that?
>
>> Removing attr_accesible is a very bat idea.
>
> He hasn't said anything about removing attr_accesible - he's removed
> the attr_accessor definitions - which is correct if he's got fields
> for those values he doesn't need to create accessors for them.
>
> The question might be to check with the OP whether he *really* needs
> to store the calculated value, or whether it would just be easier to
> have a method (similar to the one you proposed, but using the correct
> calculation) to return the value when asked. I suppose it depends
> whether he's doing a lot of DB queries on the quantity_sold - in which
> case it might be better to have it in the DB, of if it's just for use
> in views, then possible a (memoized) calculated value might be
> "better" to prevent any risk of the values getting out-of sync
> (nothing worse than someone running an update on the db and changing
> values without updating the calculated values...)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
Enviado desde mi dispositivo móvil

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to