Override form data


#1

would anyone be willing to provide a code sample demonstrating how to
override form field data, or simply the best way and place to access
it before action is taken on it? A link to an example would be great
as well.

thanks,
rich


#2

On Thursday 17 November 2005 22:05, Rich B. wrote:

would anyone be willing to provide a code sample demonstrating how
to override form field data, or simply the best way and place to
access it before action is taken on it? A link to an example would
be great as well.
If I understood what you meant correctly, then something like this
should work:

class MyController < ApplicationController

before_filter :convert_timezone, :only => [ :create ]

def create
# here @params[:timezone] is already an instance of TimeZone
end

def convert_timezone
return unless @params[:timezone]
@params[:timezone] = TimeZone.new(@params[:timezone])
end
end

Hope that helps