Rails collection_select default option?

Add the :selected option.

Example:

collection_select(:post, :author_id, Author.all, :id, :name_with_initial, {:selected => "whatever_value"})

Example took from: ApiDock

In your case:

<%= collection_select :PriceRange, "7", PriceRange.where('value > 0'), :value, :name, {:selected => "whatever"} %>

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)