Francois Beausoleil wrote:
Hi all !
------------------------------------------------------------------------
r3679 | bitsweat | 2006-02-26 19:27:48 -0500 | 1 line
Define attribute query methods to avoid method_missing calls. Closes #3677.
------------------------------------------------------------------------
Unfortunately, that changeset causes problems with my code...
I have a table named estimate_lines, with the following columns:
id
position
estimate_id
product_id
quantity
unit_price
comment
line_type
r3679 now always defines reader, writer and reader? methods. My model
looks like this:
class EstimateLine < ActiveRecord::Base
belongs_to :estimate
belongs_to :product
def comment?()
line_type == 'comment'
end
# other methods removed
end
What happens is that my #comment? method is overriden by ActiveRecord.
That's BAD. Of course, my method is just a shortcut for the query,
and it could probably be replaced with an STI, but you know, I was
young back then...
On the other hand, my quote objects have a #paid_in_full? method as
well as a column with the same name. The implementation checks some
things before replying, but is a side-effect free operation. The
column is there as a cache of the value, which I update through other
means.
I would propose to update this changeset to implement the method, only
if it is currently undefined. Same goes for reader and writer
methods, I would guess. Haven't tested, but does this changeset
overwrite custom attribute getters/setters ?
My original implementation for 0.14.1 only defined readers if they
weren't defined already. I'll have a look at #3679 w.r.t. reader?
-- stefan
--
For rails performance tuning, see: http://railsexpress.de/blog
Subscription: http://railsexpress.de/blog/xml/rss20/feed.xml
_______________________________________________
Rails-core mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-core