Created
October 16, 2008 19:16
-
-
Save agibralter/17234 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- fields_for @user do |f| | |
%label{:for => "email"} email | |
= f.text_field :email | |
= f.error_message_on :email | |
.password | |
%label{:for => "password"} password | |
= f.password_field :password | |
= f.error_message_on :password | |
.password_confirmation | |
%label{:for => "password_confirmation"} confirm password | |
= f.password_field :password_confirmation | |
= f.error_message_on :password_confirmation | |
.gender | |
%label{:for => "gender"} gender | |
= f.select :gender, select_opts(:gender) | |
= f.error_message_on :gender | |
.year | |
%label{:for => "year"} year of birth | |
= f.select :year, select_opts(:year_of_birth) | |
= f.error_message_on :year | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module UsersHelper | |
def select_opts(sym) | |
case sym | |
when :gender then gender | |
when :year_of_birth then year_of_birth | |
else nil | |
end | |
end | |
private | |
def gender | |
[nil, "f", "m"] | |
end | |
def year_of_birth | |
this_year = Time.now.strftime("%Y").to_i | |
[nil] + ((this_year-100)..this_year).to_a.reverse | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment