Reputation: 42523
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
Upvotes: 7
Views: 12840
Reputation: 8116
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) %>
Upvotes: 17