how do I change my activerecord model default behavior for the find method?
For example, i want to search for all books inside drupal nodes database, but drupal uses only one table for all data, and uses the ‘type’ column to find out the type
class Book < ActiveRecord::Base
set_table_name 'node'
def find(*args)
:conditions => {:type => 'book'}
super
end
end
this is the correct approach to solve this problem?
I’ve solved this creating a model for Node and using named_scopes
the result was this
it works, but doesn’t look like the rails way of doing stuff. If I get enought time soon, I’ll try to write a library to access drupal data using something like acts_as_drupal_node
now i can fetch all book entries using: