Sachin Prasad
Sachin Prasad

Reputation: 5411

Display us states dropdown on view in rails

I have implement a helper which contains list of US states. Please check here:

Rails Select Drop Down for States?

Now I have to display the selected US state name on the view file. How can I access that?

As long as it is a drop-down it is working fine.

For example my user selected Maryland ,in the database the value inserted is MD. Now,I have to display Maryland on the view page.

Please note I have simply created a helper named us_states in ApplicationHelper.

Upvotes: 0

Views: 1736

Answers (1)

Bob
Bob

Reputation: 2121

May be:

us_states.select{|v| v[1]=="WA"}.first[0]

Upvotes: 1

Related Questions