Forum: Ruby on Rails Format Values from a date_select

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.
ss (Guest)
on 2006-06-05 18:06
Hi

I have two date select options in a form, when I try and grab these
values using somthing like

@pMax = params[:max]

I get this in the varibale name

max(1i)2006max(2i)6max(3i)5

which has the correct data, jsut with added things like max(1i)

Whats the best way of grabbbing this data into a variable without the
extra titles?

Scott
Mark Reginald J. (Guest)
on 2006-06-05 23:45
(Received via mailing list)
ss wrote:
>
> Whats the best way of grabbbing this data into a variable without the
> extra titles?

Since it appears that the date is not destined for a (DB-backed) model
attribute of type Date, but for a plain instance variable, use
select_date
instead, with its prefix option set to 'max'. Then in your controller:

   m = params[:max]
   @pMax = Date.new(m[:year], m[:month], m[:day])


--
We develop, watch us RoR, in numbers too big to ignore.
This topic is locked and can not be replied to.