# Get parameters from datetime\_select

**URL:** <https://www.ruby-forum.com/t/get-parameters-from-datetime-select/191636>\
**Category:** Rails\
**Created:** [July 15, 2010, 5:28pm UTC](https://www.ruby-forum.com/t/get-parameters-from-datetime-select/191636 "2010-07-15T17:28:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon\_comp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@anon\_comp](https://www.ruby-forum.com/u/anon_comp)\
**Post date:** [July 15, 2010, 5:28pm UTC](https://www.ruby-forum.com/t/get-parameters-from-datetime-select/191636/1 "2010-07-15T17:28:24Z")

</div>

I am using datetime\_select to get the date and time from the user to  
execute a certain program (details unrelevant). What I need to do is  
to take certain parts from datetime\_select and manipulate/use them.

## In my view

\<% form\_for(@schtask) do |f| %\>

Scheduled Time  
 \<%=h f.datetime\_select(:schtime, :prompt =\> {:month =\> 'Select month', :day =\> 'Select day', :hour =\> 'Select hour', :minute =\> 'Select minute'}, :start\_year =\> Time.now.year, :order =\> [:month, :day, :year, :hour, :minute], :minute\_step =\> 5)%\>

\<%= f.submit 'Create' %\>

\<% end %\>
## My attempt to get the :day parameter from datetime\_select in the controller

def schedule  
@schtask = Schtask.find(params[:id])  
@day = params[‘schtime(3i)’] #this results in a nil  
#@day = @schtask.schtime.day  
end

Note: schtime parameter is a datetime type in the database

I’d appreciate any help

Thanks,  
Anon\_comp

---

<div class="post-metadata">

**Author:** ![anon\_comp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@anon\_comp](https://www.ruby-forum.com/u/anon_comp)\
**Post date:** [July 15, 2010, 5:41pm UTC](https://www.ruby-forum.com/t/get-parameters-from-datetime-select/191636/2 "2010-07-15T17:41:52Z")

</div>

On 15 July 2010 16:27, anon\_comp [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ## month’, :day =\> ‘Select day’, :hour =\> ‘Select hour’, :minute =\> controller
> 
> def schedule  
> @schtask = Schtask.find(params[:id])  
> @day = params[‘schtime(3i)’] #this results in a nil  
> #@day = @schtask.schtime.day  
> end
> 
> Note: schtime parameter is a datetime type in the database

Have a look in the log to see how it is being passed in the params.  
If you still can’t work it out break into your code using ruby\_debug  
and have a look at params to see what it consists off. I think you  
will find that schtime is inside schtask in the params hash. If you  
have not used ruby\_debug have a look at the rails guide on debugging.

Colin

---

<div class="post-metadata">

**Author:** ![anon\_comp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@anon\_comp](https://www.ruby-forum.com/u/anon_comp)\
**Post date:** [July 15, 2010, 6:36pm UTC](https://www.ruby-forum.com/t/get-parameters-from-datetime-select/191636/3 "2010-07-15T18:36:54Z")

</div>

On Jul 15, 11:39 am, Colin L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > In my view  
> > \<%= f.submit ‘Create’ %\>  
> > end
> 
> > Note: schtime parameter is a datetime type in the database
> 
> Have a look in the log to see how it is being passed in the params.  
> If you still can’t work it out break into your code using ruby\_debug  
> and have a look at params to see what it consists off. I think you  
> will find that schtime is inside schtask in the params hash. If you  
> have not used ruby\_debug have a look at the rails guide on debugging.

I’ve looked in the log and the parameter passed is schtime(3i). I  
tried doing @day = @schtask.schtime(3i), but the RadRails IDE is not  
reading the parenthese and 3i as part of schtime. I’ll try  
ruby\_debug…
