Select specific option in helper rails

1. If you used  options_for_select in your  helper, then selected will work like this 

= :country_id, options_for_select(@countries.collect{|c|[,]}, {selected: @hotel.country_id}), {include_blank: true}

2. Otherwise use this

= :city_id, @cities.collect{|c| [,] }, { selected:  @hotel.city_id, include_blank: true}

I am Senior Software Engineer. I love reading, writing, sharing,developing, hiking, movies, trips, mountains, brooks, hills etc.

Tagged with: ,
Posted in Ruby Little Codes

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: