views:

22

answers:

1

Hi

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

+1  A: 

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)  %>
AboutRuby