Remix The wrote:
've been working on this problem for a couple days now, and i haven't
found out why visitors can't sign up, but no errors are shown (through
error_messages_for).
here is my model view and controller for sign up
Parked at Loopia
any ideas?
you can try it to see what happens when a form is submitted,
talkingbubbles.com
What controller/action is rendering signup.rhtml? You haven't specified the originating action.
Try putting in something like:
<% form_for :user, :url => {:controller => "users" :action => "signup"} do |f| -%>
Remix The wrote:
if i comment out rescue, this is what i get:
ActiveRecord::RecordInvalid in UsersController#signup
Validation failed:
[...]
Request
Parameters: {"commit"=>"Sign up", "password_confirmation"=>"mine", "password"=>"mine", "login"=>"testing", "email"=>"testing"}
does this give any clues as to why validation is not passing?
I don't know what your table definition looks like so at this point I would suggest stripping out the validations from your model until you find the one(s) that is triggering the error.
theRemix wrote:
Michael Wang wrote:
I don't know what your table definition looks like so at this point I
would suggest stripping out the validations from your model until you
find the one(s) that is triggering the error.
i commented out all validations... same thing, no difference... maybe
the 'problem' occurs before this?
I would dump out the contents of params[:user] to your log file and see if there's something funny in there. E.g.:
def signup
logger.debug(params[:user].inspect)
@user = User.new(params[:user])
logger.debug(@user.inspect)
This assumes you are running development mode. You'll need to use another logger level if you are running in production (like logger.warn).
theRemix .. wrote:
Michael Wang wrote:
theRemix wrote:
Michael Wang wrote:
I don't know what your table definition looks like so at this point I
would suggest stripping out the validations from your model until you
find the one(s) that is triggering the error.
i commented out all validations... same thing, no difference... maybe
the 'problem' occurs before this?
I would dump out the contents of params[:user] to your log file and see
if there's something funny in there. E.g.:
def signup
logger.debug(params[:user].inspect)
@user = User.new(params[:user])
logger.debug(@user.inspect)
This assumes you are running development mode. You'll need to use
another logger level if you are running in production (like logger.warn).
--
Michael Wang
Processing UsersController#signup (for 127.0.0.1 at 2007-03-11 04:36:26) [POST]
Session ID: 311060b70cf8ee0f1909a2159b21a6e0
Parameters: {"commit"=>"Sign up", "password_confirmation"=>"mine", "action"=>"signup", "controller"=>"users", "login"=>"help", "password"=>"mine", "email"=>"please"}
User Columns (0.000718) SHOW FIELDS FROM users
User Load (0.000271) SELECT * FROM users ORDER BY created_at DESC LIMIT 5
Dream Columns (0.000615) SHOW FIELDS FROM dreams
Dream Load (0.000219) SELECT * FROM dreams WHERE (dreams.deleted_at IS NULL OR dreams.deleted_at > '2007-03-11 04:36:26') ORDER BY comments_count desc LIMIT 5
nil
#<User:0x2ad0c96b1f10 @attributes={"salt"=>nil, "city"=>nil, "name"=>nil, "updated_at"=>nil, "zip"=>nil, "crypted_password"=>nil, "remember_token_expires_at"=>nil, "country"=>nil, "remember_token"=>nil, "login"=>nil, "created_at"=>nil, "state"=>nil, "email"=>nil}, @new_record=true>
SQL (0.000038) BEGIN
SQL (0.000032) ROLLBACK
Rendering actionsignuplayoutfalse within layouts/default
Rendering users/signup
Rendered layouts/_signup (0.00011)
Comment Columns (0.000586) SHOW FIELDS FROM comments
Rendered layouts/_footer (0.00029)
Completed in 0.02685 (37 reqs/sec) | Rendering: 0.00775 (28%) | DB: 0.00248 (9%) | 200 OK [http://localhost/users/signup\]
commit and password_confirmation are not part of the model and so User.new is failing. Delete those keys out of params[:user] or don't store them in params[:user] when you create the form or set the the attributes manually. E.g.:
@user = User.new
@user.login = params[:user][:login]
@user.email = params[:user][:email]
...
or
@user = User.new(:login => params[:user][:login],
:email => params[:user][:login], ...)
theRemix .. wrote:
Michael Wang wrote:
theRemix .. wrote:
--
LIMIT 5
SQL (0.000038) BEGIN
SQL (0.000032) ROLLBACK
Rendering actionsignuplayoutfalse within layouts/default
Rendering users/signup
Rendered layouts/_signup (0.00011)
Comment Columns (0.000586) SHOW FIELDS FROM comments
Rendered layouts/_footer (0.00029)
Completed in 0.02685 (37 reqs/sec) | Rendering: 0.00775 (28%) | DB: 0.00248 (9%) | 200 OK [http://localhost/users/signup\]
commit and password_confirmation are not part of the model and so User.new is
failing. Delete those keys out of params[:user] or don't store them in
params[:user] when you create the form or set the the attributes manually. E.g.:
@user = User.new
@user.login = params[:user][:login]
@user.email = params[:user][:email]
...
or
@user = User.new(:login => params[:user][:login],
:email => params[:user][:login], ...)
--
Michael Wang
hmmm... i'm surprised to say that nothing has changed.. i really thought that's where i went wrong.
def signup
@user = User.new( :login => params[:login],
:email => params[:email],
:password => params[:password],
:password_confirmation => params[:password_confirmation])
return unless request.post?
@user.save!
self.current_user = @user
redirect_back_or_default(:controller => '/', :action => 'index')
flash[:notice] = "Thanks for signing up!"
rescue ActiveRecord::RecordInvalid
render :action => 'signup'
end
same result, validation fails
Why are you using params[:login] instead of params[:user][:login]? Did you change your form? Which validation is it failing on?