This patch allows you to alias your model methods as some other desired field name in the ferret index. For instance, if you had a model method called 'media_type' but want the field in the ferret index to be just 'type', you can do it as follows:
class Media < ActiveRecord::Base
acts_as_ferret(:fields => {:name => {},
:media_type => {:alias => :type},
:price_in_dollars => {:alias => :cost, :index => :untokenized}},
:ferret => {:default_field => [:name, :type]})
end
Now when you search, you can use a query as follows:
name:tool type:cd cost:9
(To find all $9 cds with 'tool' in the name.)
Note that when the default search fields are specified, you refer to the alias. This is because, to ferret, the field is named for the alias, not the model method where the data comes from. As far as ferret knows, that is the real field.
I added the ability to alias for two reasons. First, because it frees me to name my methods descriptively and still have the field names in the query be easy and short. Obviously in a search for media, type is going to refer to a media type... the user shouldn't have to use 'media_type:cd' when 'type:cd' will suffice.
Second, and more importantly, certain methods are reserved by rails/ruby (like 'type') so you can't (easily) get away with using them for method names.
Xichekolas