Forum: Ruby on Rails override form data

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
rbrant (Guest)
on 2005-11-17 17:05
(Received via mailing list)
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
dmitry (Guest)
on 2005-11-17 22:32
(Received via mailing list)
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
This topic is locked and can not be replied to.