Q: How to set default value for dropdown menu on rails? I have following code 
        <select name="status_drop" id="status" selected="<%=session[:status]%>" >
            <option value="0">Completed</option>
            <option value="1">Not Completed</option>
        </select>

I have session call session[:status] it hold either 1 or 0 and I need to set default value according to the session[:status] value. Please can some one help on this problem ? 

A: You can try that
<select name="status_drop" id="status">
    <option value="0"<%= ' selected="selected"' if session[:status] == 0 %>>Completed</option>
    <option value="1"<%= ' selected="selected"' if session[:status] == 1 %>>Not Completed</option>
 </select>

