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| %> <p> Scheduled Time<br/> <%=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)%> </p> <p> <%= f.submit ''Create'' %> </p> <% 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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 15 July 2010 16:27, anon_comp <neocoolstar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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| %> > <p> > Scheduled Time<br/> > <%=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)%> > </p> > <p> > <%= f.submit ''Create'' %> > </p> > <% 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 databaseHave 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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jul 15, 11:39 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 15 July 2010 16:27, anon_comp <neocools...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > 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| %> > > <p> > > Scheduled Time<br/> > > <%=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)%> > > </p> > > <p> > > <%= f.submit ''Create'' %> > > </p> > > <% 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 > > 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... -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.