Skip to content

Instantly share code, notes, and snippets.

@agibralter
Created October 16, 2008 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agibralter/17234 to your computer and use it in GitHub Desktop.
Save agibralter/17234 to your computer and use it in GitHub Desktop.
- fields_for @user do |f|
.email
%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
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