views:

73

answers:

2

I have a website with several forms that all pass the same set of arguments to error_messages_for. Is there a way for me to configure rails to use my default arguments other than creating a helper method which wraps error_messages_for with my arguments?

+1  A: 

No it's not. The error_messages_for function doesn't relies on any options.

So I guess the best solution is, as you say, to create a helper method to retrieve your arguments.

def my_default_error_options(options = {})
    { :value => true }.merge!(options)
end

error_messages_for my_default_error_options

And if you need some extra options specifically for one call :

error_messages_for my_default_error_options({:value => false})
Damien MATHIEU
A: 

A quick read of the code suggest you can't. I'd go with the helper route, or monkey patch error_messages_for.

Jim Zajkowski