Created
October 11, 2008 22:30
-
-
Save agibralter/16334 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
#new-user | |
- form_for @user, :url => users_path 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 | |
.user-profile | |
- f.fields_for @user.user_profile do |p| | |
.gender | |
%label{:for => "gender"} gender | |
= p.select :gender, select_opts(:gender) | |
= p.error_message_on :gender | |
.year | |
%label{:for => "year"} year | |
= p.select :year, select_opts(:year_of_birth) | |
= p.error_message_on :year | |
%div | |
= submit_tag 'join the urtak project' | |
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
class User < ActiveRecord::Base | |
# ... | |
has_one :user_profile | |
# ... | |
end | |
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
class UsersController < ApplicationController | |
before_filter :login_required, :except => [:new, :create] | |
def new | |
@user = User.new | |
@user.build_user_profile | |
end | |
def create | |
begin | |
@user = User.new(params[:user]) | |
@user.build_user_profile(params[:user][:user_profile]) | |
@user.save! | |
self.current_user = @user | |
flash[:notice] = "Thanks for signing up!" | |
redirect_to home_path | |
rescue | |
flash[:warning] = "Please fix the errors below." | |
render :action => 'new' | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment