Thanks. That's the help I needed. Now I have a hash and I feed the keys to the options. In the controller I use the returned key to get my date values. Works great.
On Mar 11, 11:14 pm, Matt Jones <[email protected]> wrote: > On Mar 11, 2010, at 10:38 PM, Zooper wrote: > > > > > > > I need year to date and month to date creation date filters on table- > > plus. I followed the agility tutorial except that I created the > > options array as follows: > > > periods = [[:YTD, Date.civil(Date.today.year,1,1)-1] , > > [:MTD, Date.civil(Date.today.year,Date.today.month, > > 1)-1]] > > > I subtract a day from the dates so i can use the created_after scope. > > > Using <filter-menu param-name="start_date" options='&periods'/> > > prependend to the table-plus header works, and my controller applies > > the scope created_after((params[:start_date]). Everything does what > > I expect it to except that the filter always goes back to All. As I > > looked through the posts, I saw that a much earlier release of Hobo > > had this problem, but it was fixed a while ago. The only difference > > I can see between what I am doing and the tutorial is that I am > > manually creating my options. Is the easiest way to fix this to > > create a model for a period table? > > This looks like a common issue people run into with option_for_select > (the Rails helper that's generating the menu). For the correct option > to stay selected, the 'lasts' have to directly match the value coming > in via the params array (a string). So having Date values in there > won't work well at all... > > On reflection, though, how does filter-menu EVER work properly with an > array like that? I'm 90% sure I've used it before, but the check that > finds the selected element won't work (o.to_s will not be right). Tom, > Bryan - thoughts? Should probably fix that. > > --Matt Jones- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Hobo Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.
