i was wondering if there was a nice clean way(after all, it is ruby) to
change the find method of a certain model/class (Page) so that if i
wanted to use a find method on a @page instance it would return only
specific rows from the table(if the page.published == true/false:
the pages table looked like
id int not null auto_increment,
published tinyint(1) not null,
something varchar not null,
end of table
and i had a query:
@page = Page.find(:all)
it would return only the pages that had pages.published == true.
i thought the def would be something like:
Class Page < ActiveRecord::Base
self.find(:all, :conditons => ‘published=1’)
but it isn’t working.
could possibly do
self.find(:all, :conditons => …)
and change all of my find methods to @page.find_published…?
am i going down the wrong train of thought? where/how do i change a
class method to my own needs without ruining the initial method…?
thanks for any reference,