how to call a function in model and pass values in

Assuming what you're wanting to do is create a method that exists for
all AR descendants and can be set as a before_save hook whenever you
call something similar to 'before_save :test => :title, :content' then
you could always write your own class method like this:

<code language="ruby">
class ActiveRecord::Base
  class << self
    # This class method just defines a new aptly named instance method
    # that is then registered with before_save. The new instance
method
    # is a simple delegate to the real Model#test method you already
have
    # defined and working.
    def test(*attrs)
      self.class_eval <<-EOC
        def before_save_test_#{attrs.join('_and_')}
          self.test(*#{attrs.inspect})
        end
        before_save :before_save_test_#{attrs.join('_and_')}
      EOC
    end
  end

  # Here is the stub for your real Model#test method. It will be
  # called with the exact list of arguments given to the
  # Model.test class method.
  def test(*attrs)
    puts "instance test called with #{attrs.inspect}"
  end
end
</code>

And then use it like this:

<code language="ruby">
class Post < ActiveRecord::Base
  test :title, :content
end
</code>

Obviously, you'll need to ensure that the snippet above defining the
custom class method gets loaded after ActiveRecord::Base does or re-
factor it to ensure AR is loaded as a result of this snippet being
evaluated.