Set the html_options parameter in collection_select to { :selected => 
params[:friend_type] } 

On Tuesday, February 28, 2012 7:44:01 PM UTC-8, Gitted wrote:
>
> I have a form_for like:
>
> <%= form_for @user, ....   |f| %>
>
> <%= f.collection_select :friend_type, FriendType.all, :id, :name %>
>
>
> Now in my new action, I set the friend_type from the querystring, so it 
> already has a value of e.g. 3 (which is the id).
>
> How can I have this pre-selected when it renders?
>
>
>
On Tuesday, February 28, 2012 7:44:01 PM UTC-8, Gitted wrote:
>
> I have a form_for like:
>
> <%= form_for @user, ....   |f| %>
>
> <%= f.collection_select :friend_type, FriendType.all, :id, :name %>
>
>
> Now in my new action, I set the friend_type from the querystring, so it 
> already has a value of e.g. 3 (which is the id).
>
> How can I have this pre-selected when it renders?
>
>
>
On Tuesday, February 28, 2012 7:44:01 PM UTC-8, Gitted wrote:
>
> I have a form_for like:
>
> <%= form_for @user, ....   |f| %>
>
> <%= f.collection_select :friend_type, FriendType.all, :id, :name %>
>
>
> Now in my new action, I set the friend_type from the querystring, so it 
> already has a value of e.g. 3 (which is the id).
>
> How can I have this pre-selected when it renders?
>
>
>
On Tuesday, February 28, 2012 7:44:01 PM UTC-8, Gitted wrote:
>
> I have a form_for like:
>
> <%= form_for @user, ....   |f| %>
>
> <%= f.collection_select :friend_type, FriendType.all, :id, :name %>
>
>
> Now in my new action, I set the friend_type from the querystring, so it 
> already has a value of e.g. 3 (which is the id).
>
> How can I have this pre-selected when it renders?
>
>
>
On Tuesday, February 28, 2012 7:44:01 PM UTC-8, Gitted wrote:
>
> I have a form_for like:
>
> <%= form_for @user, ....   |f| %>
>
> <%= f.collection_select :friend_type, FriendType.all, :id, :name %>
>
>
> Now in my new action, I set the friend_type from the querystring, so it 
> already has a value of e.g. 3 (which is the id).
>
> How can I have this pre-selected when it renders?
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/XeKXSvxhJyQJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to