0

I am developing a Rails application using ActiveScaffold and I am stuck with the fact that I need to do a date range filter.

I need to do a date range search (equivalent SQL => 'WHERE created_at BETWEEN :date_1 AND :date_2'). For that, I need to tell AS to display two text fields with datepickers (that part is pretty easy with jQuery datepicker, thank you for pointing me there).

An example would be:

text_field_tag :date_from, ''
text_field_tag :date_to, ''

I'm stuck at telling AS that :date_from and :date_to belong to the same column => created_at

I've tried to do an override search in the helper,creating there the two text_fields, It will only display one text_field.

I've tried to create virtual columns linking them to the created_at, didn't work.

Anyone had to face this situation with AS before? Any advice would be appreciated.

Wiggin
  • 329
  • 1
  • 3
  • 17
  • so if :date_from and :date_to refer to same column, '`created_at`, how are you differentiating them? can you post complete view of what you tried – Wally Ali May 13 '14 at 23:20
  • I don't understand what the problem really is, what's wrong with basic `Something.where("created_at > ? AND created_at < ?", params[:date_from], params[:date_to])`? – Mike Szyndel May 13 '14 at 23:20
  • @MichaelSzyndel the problem is that in AS you don't have the conventional actions like index,new,edit,etc.. where you can do the params[:date_from]. – Wiggin May 14 '14 at 08:36
  • @WaliAli AS doesn't provide a file for you to edit, so I can't post a view of what I've tried. The only thing AS allows me to edit is the controller or the helper if I create one. – Wiggin May 14 '14 at 08:37
  • I just googled active scaffold. it is something alien to me. Sorry that I couldn't help you. – Wally Ali May 14 '14 at 12:38

0 Answers0