I want to have a drop down on a form that shows in plain English “1 day before, 2 days before” etc a given date as well as “1 days after, 2 days after”.
How can I do this with Rails date_select?
Thanks
Ok I am creating my own as follows but am a bit stuck:
<%= select_tag(:board,options_for_select([["On the Birthday", 0], ["1 Day Before", -1], ["Two Days Before", -2], ["Three Days Before", -3]]), { :class => "default" }) %>
Now what I want to do is to show the number of days the user has saved. So how can I program or set the select so it knows which value to select.
I have the delivery date saved in a table and can access it as follows:
@board.deliver_on
Thanks.
Put simply: you can’t do it with a
date_select. You would need to build it using either theselectorcollection_selecthelpers and work out the values for the dates yourself. There is no helper in Rails to do that as far as I am aware.