I want my text_field_tag
to have the current date as a default value if the params for params[:date] is empty, here is my code at the moment:
<%= text_field_tag :end, params[:end] %>
i want somthing like: <%= text_field_tag :end, if params[:end] then use this value else show current date %>
thank you
You can simply use the "or" operator. If params[:end] is empty, it'll use Time.now.
<%= text_field_tag :end, (params[:end] or Time.now) %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With