I have this code: <%= date_select("post", "from") %> simple, easy, works! The problem comes when I need to build a query around these dates. In my log I see that the params are being passed like this: "post"=>{"from(1i)"=>"2008", "to(1i)"=>"2008", "from(2i)"=>"11", "to(2i)"=>"11", "from(3i)"=>"6", "to(3i)"=>"6"} When I try and access the params, such as, by saying: params[:to][:3i], ruby barks at me. All other variations have failed to get at the values. So, my question is this: how in the name of everything holy am I supposed to get the month, day, and year from the params hash when hashes containing integers - 1, 2, 3, etc. - are inaccessable via ruby. I have tried putting the values into a date object and everythign simply does not work or come out as nil. Has anyone had any success at getting at those values? Thanks, -S -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> I have this code: <%= date_select("post", "from") %> > > simple, easy, works! The problem comes when I need to build a query > around these dates. In my log I see that the params are being passed > like this: > > "post"=>{"from(1i)"=>"2008", "to(1i)"=>"2008", "from(2i)"=>"11", > "to(2i)"=>"11", "from(3i)"=>"6", "to(3i)"=>"6"} > > When I try and access the params, such as, by saying: params[:to][: > 3i], > ruby barks at me. All other variations have failed to get at the > values. > So, my question is this: how in the name of everything holy am I > supposed to get the month, day, and year from the params hash when > hashes containing integers - 1, 2, 3, etc. - are inaccessable via > ruby. > I have tried putting the values into a date object and everythign > simply > does not work or come out as nil. Has anyone had any success at > getting > at those values? Thanks,Maybe I''m not understanding but why not access params[:post][:from] and then request what parts you want using DateTime methods. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom wrote:>> 3i], >> at those values? Thanks, > Maybe I''m not understanding but why not access params[:post][:from] > and then request what parts you want using DateTime methods.it doesn''t complain when I do that but it doesn''t give any values back either. If I try params[:to][:1i] it complains about the number, if I try params[:to]["1i"] I get You have a nil object when you didn''t expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.[] Parameters: {"commit"=>"Submit", "post"=>{"from(1i)"=>"2008", "to(1i)"=>"2008", "from(2i)"=>"11", "to(2i)"=>"11", "from(3i)"=>"6", "to(3i)"=>"6"}} Right now I am lost on what to do because this should be simple. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
This may just be superstition talking, but I wonder if the problem is the names "from" and "to". Any difference if you make those, e.g., "from_date" and "to_date"? -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk@googlegroups.com] On Behalf Of Shandy Nantz Sent: Thursday, November 06, 2008 3:11 PM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Re: Beyond frusterating date_select issue Philip Hallstrom wrote:>> 3i], >> at those values? Thanks, > Maybe I''m not understanding but why not access params[:post][:from] > and then request what parts you want using DateTime methods.it doesn''t complain when I do that but it doesn''t give any values back either. If I try params[:to][:1i] it complains about the number, if I try params[:to]["1i"] I get You have a nil object when you didn''t expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.[] Parameters: {"commit"=>"Submit", "post"=>{"from(1i)"=>"2008", "to(1i)"=>"2008", "from(2i)"=>"11", "to(2i)"=>"11", "from(3i)"=>"6", "to(3i)"=>"6"}} Right now I am lost on what to do because this should be simple. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 Nov 6, 11:11 pm, Shandy Nantz <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Philip Hallstrom wrote: > >> 3i], > >> at those values? Thanks, > > Maybe I''m not understanding but why not access params[:post][:from] > > and then request what parts you want using DateTime methods. > > it doesn''t complain when I do that but it doesn''t give any values back > either. If I try params[:to][:1i] it complains about the number, if I > try params[:to]["1i"] I getYour''re trying too hard. params[''post''][''to(1i)''] etc... (or use select_date ) Fred> > You have a nil object when you didn''t expect it! > You might have expected an instance of ActiveRecord::Base. > The error occurred while evaluating nil.[] > > Parameters: > > {"commit"=>"Submit", > "post"=>{"from(1i)"=>"2008", > "to(1i)"=>"2008", > "from(2i)"=>"11", > "to(2i)"=>"11", > "from(3i)"=>"6", > "to(3i)"=>"6"}} > > Right now I am lost on what to do because this should be simple. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---