I've overrode the method find
for ActiveRecord::Base
and that went pretty well, now I can customize it nicely.
def self.find(*args)
# my custom actions
super(*args)
end
then
Album.find(1) #=> My custom result
But now I would like to override this:
Album.first.photos
and I'm not sure what method exactly I should override to get the job done... I'm thinking of something specifically for associative queries, but I'm not sure :(
I need to act on 'ActiveRecord::Base' suggesting dynamic classes so I couldn't create a method photos
for that, but a method that will interact within all the models I try.
Thanks a lot
Update
For better explaining what I'm trying to achieve:
Is to create a pluggable ruby gem for use with rails and that gem can simply take you ID structure from the database and convert it on the fly to a shorten ID just like bit.ly system. but this is done on the fly with only declaring has_shortened :id
to your model, and then all the interface and queries return for example DH3
instead of 12
for example, I've managed to get this working this the point I need to deal with associataions.
Follow the gem url http://github.com/ludicco/shortener so you can check it out, and feel free to come with ideas you might have to implement it if you think it's a nice idea.
Cheers