Determining the member type in Params Hash

Is there an easy way to determine what is the "type" of a member in the Params hash? The reason that I ask this question is that I have to make adjustments for UK dates in the params hash for date and datetime fields.

The date and datetime fields are being returned as Strings. So when I assign the hash to an instance variable's attributes as follows:

@entry.attributes = params[:entry]

for example. The program errors out. I have to Normalize the String representation of UK dates in in US dates (still String format) before the

    lvar = params[:entry]     unless lvar[:example_date].nil?       lvar[:date] = ParseDate.normalize_date(lvar[:example_date])     end     @entry.attributes = lvar

statement is executed and then everything works fine. But this is a lot of ugly duplicate coding accounting for specific members of params hash that are date and datetime type. I was hoping that there might be an elegant solution to this problem. Thanks in advance for your time. Bharat

Although my Rails-fu is only of moderate strength...

The only thing determining the expected type of a particular params hash value (they are all strings as you said) is the intended receiver... which sounds like a model to me (@entry)... which would make the translation from UK to US the model's business... which would lead me to create a model method to employ between the params hash and the model assignment

@entry = 'US', params[:entry]

or something like that.

The localized method could check just the params attributes necessary (Entry knows which attributes it has to check, other models know their attributes), and the code that actually does the normalization per attribute might go in a helper, a module, or as part of a superclass between AR and Entry depending on how often it was used.

Fred probably has a better way though... :wink:

Thanks Ar for your response. If someone can add a bit more clarity to this then I can run with it. Fred? Anyone?