How to add parameter and condition in function dynamically??

Hi All,
       I have one function in that function i wanna add parameters and
conditions dynamically.

I hope you got me if yes please tell me what should i do.

Thanks
Varun Kumar

Hi All,
      I have one function in that function i wanna add parameters and
conditions dynamically.

I hope you got me if yes please tell me what should i do.

You're going to have to be more specific.

Fred

If you have:

def foo(*bar)
  bar.class # => Array
end

So the parameters becomes an array of values, including an empty array
if nothing is passed in.

Then you can do stuff like:

foo
foo "one", "two"
foo :a => "b"
etc.

Is that what you were looking for?

-Danimal

Another pseudo-random guess...

I've had several places where I've done something like this in a
controller:

FIND_OPTIONS = {:limit=>10, :offset=>0, :order=>:name}
def index
  find_options = FIND_OPTIONS.dup
  find_options.reverse_merge :name=>params[:name] if
params[:name].blank?
  ... other options...
  SomeModel.find(:all, find_options)
end

That allows you to search only for arguments that are supplied by the
user (ignoring blanks as don't cares).

If you want to only add/update data as returned from a form
submission... Rails already does that for you.