Rails form_for select tag with option selected

I am using a form_for to update a user profile.

As part of the form I am using a select menu. The menu is filled from an array ie,

STATUS = [['Active', 'active'], ['In Active', 'inactive']]

Then in the form

<%= f.select(:status, options_for_select(STATUS)) %>

While this work's its not selecting the option which was previously selected on edit.

Am I missing something ?


<%= f.select(:status, options_for_select(STATUS, :selected => params[:status])) %>

should be written as

<%= f.select :status, STATUS %>

Need Your Help

PHP / Javascript create countdown between 2 times

javascript php

I currently have many issues trying to think of how to create this script.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.