# 2 questions: redirect and form fields

**URL:** <https://www.ruby-forum.com/t/2-questions-redirect-and-form-fields/118115>\
**Category:** Rails\
**Created:** [October 24, 2007, 12:03am UTC](https://www.ruby-forum.com/t/2-questions-redirect-and-form-fields/118115 "2007-10-24T00:03:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ccd318/32.png) [@elle](https://www.ruby-forum.com/u/elle)\
**Post date:** [October 24, 2007, 12:03am UTC](https://www.ruby-forum.com/t/2-questions-redirect-and-form-fields/118115/1 "2007-10-24T00:03:14Z")

</div>

Just three quick questions:

1. when a user logs in, how do you redirect her to the last page they  
were on?
2. what do most use for a form field that lists all the states in a  
certain country?
3. when you create a form, the default size for the form is “size” =\>

1. Now I know I can change that number but what if I wanted to leave  
it out and control the width of my fields in css? also, how do I add a  
class="" to the form field (for css styling)?

Thanks,  
Elle

---

<div class="post-metadata">

**Author:** ![elle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ccd318/32.png) [@elle](https://www.ruby-forum.com/u/elle)\
**Post date:** [October 24, 2007, 6:28am UTC](https://www.ruby-forum.com/t/2-questions-redirect-and-form-fields/118115/2 "2007-10-24T06:28:11Z")

</div>

1. you can store the last request they made in the session, then upon  
successful login, use redirect\_to to redirect them there
2. I don’t so I will defer to others
3. \<%= text\_field :obj, :method, :class =\> ‘foo’, :style =\>  
‘font-weight: bold;’-%\> #etc, etc

You should check out the full documentation at  
[http://api.rubyonrails.org](http://api.rubyonrails.org).

-Bill

---

<div class="post-metadata">

**Author:** ![elle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ccd318/32.png) [@elle](https://www.ruby-forum.com/u/elle)\
**Post date:** [October 26, 2007, 11:31pm UTC](https://www.ruby-forum.com/t/2-questions-redirect-and-form-fields/118115/3 "2007-10-26T23:31:06Z")

</div>

Thanks Bill.

I’ve tried a plugin called state\_select and it worked good as long as  
I wanted states from one country only.  
The plugin can’t display states from both US and Canada.  
So, I’ve added the following method to the application.rb:

def state\_dropdown  
states = [“Alabama”, “Alaska”, “Alberta”, “Arizona”, “Arkansas”,  
“British Columbia”, “California”, “Colorado”, “Connecticut”,  
“Delaware”, “Florida”, “Georgia”, “Hawaii”, “Idaho”, “Illinois”,  
“Indiana”, “Iowa”, “Kansas”, “Kentucky”, “Louisiana”, “Maine”,  
“Manitoba”, “Maryland”, “Massachusetts”, “Michigan”, “Minnesota”,  
“Mississippi”, “Missouri”, “Montana”, “Nebraska”, “Nevada”, “New  
Brunswick”, “New Hampshire”, “New Jersey”, “New Mexico”, “New York”,  
“Newfoundland”, “North Carolina”, “North Dakota”, “Northwest  
Territories”, “Nova Scotia”, “Nunavut”, “Ohio”, “Oklahoma”, “Ontario”,  
“Oregon”, “Pennsylvania”, “Prince Edward Island”, “Puerto Rico”,  
“Quebec”, “Rhode Island”, “Saskatchewan”, “South Carolina”, “South  
Dakota”, “Tennessee”, “Texas”, “Utah”, “Vermont”, “Virginia”,  
“Washington”, “Washington D.C.”, “West Virginia”, “Wisconsin”,  
“Wyoming”, “Yukon”]  
states.each do | s |  
 s   
end  
end

And I wanted to ask:

1. Is this the right place to add this method?
2. Would the above work?

Thanks,  
Elle

---

<div class="post-metadata">

**Author:** ![elle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ccd318/32.png) [@elle](https://www.ruby-forum.com/u/elle)\
**Post date:** [October 26, 2007, 11:46pm UTC](https://www.ruby-forum.com/t/2-questions-redirect-and-form-fields/118115/4 "2007-10-26T23:46:53Z")

</div>

> So, I’ve added the following method to the application.rb:

Actually meant application\_helper.rb

Elle
