Redirect_to error

Hi,

I have a redirect_to statement in a method that I would like to have
at the end of the method to take you to a ‘Success’ page if
everything works.

When I hit the redirect_to statement, ( redirect_to :action =>
‘show_success’ )
I get this in the browser:

Application error

Rails application failed to start properly"

The development.log shows the redirect working just fine, but the url
doesn’t change in the browser and I get the “Application error.” If
I copy the url, from the redirected to message in the log, it
displays the page happily, so the url is correct.

In fact, if I move the redirect_to statement to different locations
in the method, it either works just fine or causes the behavior
described above. The key seems to be the @user. save statement.
Anywhere before that statement, the redirect works perfectly.
Anywhere after it, the error occurs.

This is happening on rails v1.0.0 ( Ruby v 1.8.4 ) running on Unix.

There is clearly something I am missing here - and I would really
appreciate any suggestions!

Thanks,
Denise

“Denise E.” [email protected] wrote in
message news:[email protected]

Application error
above. The key seems to be the @user. save statement. Anywhere before
that statement, the redirect works perfectly. Anywhere after it, the
error occurs.

This is happening on rails v1.0.0 ( Ruby v 1.8.4 ) running on Unix.

There is clearly something I am missing here - and I would really
appreciate any suggestions!

Thanks,
Denise

it sounds like the problem is with @user.save rather than redirect_to().
try
a simple “render :text => ‘done’” instead of redirect_to, if you still
get
the error in the same places then it’s likely it’s @user.save causing
the
problem. If you still have problems, post some code

Hi,

The render had the same problem.

With great hope, I updated my machine to run Rails 1.1, but the
situation is if anything, worse. Now, wherever in the method I put
the redirect, I get the same result, so the relationship to the save
must have been spurious. With every try, the data is properly stored
and I get the correct Redirected to http:// etc. message at the right
point. But the browser still shows the page saying “Application
error - Rails application failed to start properly.” rather than the
page we should be redirected to.

As suggested, here is the code, in case it might shed some light on
this.

def make_user_request
if request.get?
@user = User.new
else
return unless set_user_contact_info
return unless save_user_contact
logger.error(“saved user and contact info \n”)

   return unless attempt_request
   logger.error("attempted_request \n")
   mail_response(@user_request)
   logger.error("returned from mail response should redirect now

\n")
redirect_to :action => ‘show_success’
end
end

def save_user_contact

 if(  @user.save )
   logger.error("user was saved \n")
   return true
 end
 logger.error("attempt to set invalid user #{params[:user]}\n")
 flash[:notice] = "There was a problem with the data"
 return false

end

I have also tried this, though it saves the user later than I really
want - same result. In both cases the data is properly saved and the
log shows the redirect, but the browser shows the page saying
“Application error - Rails application failed to start properly.” I
also tried the same if…else structure in the save_user_contact
method, so that the redirect is in that method instead of
make_user_request. But the behavior is identical.

def make_user_request
if request.get?
@user = User.new
else
return unless set_user_contact_info

   return unless attempt_request
   logger.error("attempted_request \n")
   mail_response(@user_request)
   logger.error("returned from mail response should redirect now

\n")

   if  save_user_contact
   		logger.error("saved user and contact info \n")
   		redirect_to :action => 'show_success'
  else
   		logger.error("couldn't save user and contact info \n")
   		redirect_to :action => 'show_error'
  end
 end

end

Many thanks for any ideas.

Denise