views:

39

answers:

2

I have a action/view named: join

And I post the the 'create' action.

What should my create action look like, I want to pre-populate some fields if the creation process had an error in it (like say the email address).

So far I have:

def create

      @user = User.new(params[:user])   

      if @user.save

      end

end
+5  A: 

If you have a new action for registration, do this:

def new
  @user = User.new
end

def create
  @user = User.new(params[:user])
  if @user.save
    redirect_to success_page
  else
    render :action => "new"
  end
end
PeterWong
+4  A: 

Hi Blankman

+1 for @PeterWong but if possible why not use authentication, authorization plugin. There are many for rails, most famous ones would be

1 - Authlogic - http://github.com/binarylogic/authlogic

2 - Devise - http://github.com/plataformatec/devise

3 - REstful Authentication - http://github.com/technoweenie/restful-authentication

cheers

sameera

sameera207
+ 1 for Devise!
Zabba
+1 for all these fantastic gems.
PeterWong