[Rails] redirect_to problem

  • Thread starter Dmitry V. Sabanin
  • Start date
D

Dmitry V. Sabanin

Hi everyone!

I have a problem with my redirect_to usage. Following code in my controller,
doesn't redirects to a page, but instead gives me '200 OK' HTTP response,
with information that document was moved, and link to a page where I
redirected user to.

def destroy
user = User.find(@params["id"])
flash['notice'] = "User '#{user.name}' deleted"
user.destroy
redirect_to :action => "list"
end

This was taken almost exactly from the tutorial and it was workin' for me
nicely for a few days until I messed up something, I don't know what.
There's a set of after_filters that I use to implement nested layouts, maybe
problem is there. I'd appreciate if someone will tell me what that behavior
means, so I'll be able to investigate further. Of course I could check the
sources to see it by myself, but I'm not feeling *that* comfortable with
Rails yet :)

Thanks in advance,
 
D

David Heinemeier Hansson

This was taken almost exactly from the tutorial and it was workin' for
me
nicely for a few days until I messed up something, I don't know what.
There's a set of after_filters that I use to implement nested layouts,
maybe
problem is there. I'd appreciate if someone will tell me what that
behavior
means, so I'll be able to investigate further. Of course I could check
the
sources to see it by myself, but I'm not feeling *that* comfortable
with
Rails yet :)

It does indeed seem like you have a problem with the after filters. Try
turning them off and see if it works then. If so, I'll be happy to take
a look at your after_filters to help you figure out what the problem is
there.

If you want real time help, I can recommend trying out #rubyonrails on
FreeNet.
--
David Heinemeier Hansson,
http://www.rubyonrails.org/ -- Web-application framework for Ruby
http://www.instiki.org/ -- A No-Step-Three Wiki in Ruby
http://www.basecamphq.com/ -- Web-based Project Management
http://www.loudthinking.com/ -- Broadcasting Brain
http://www.nextangle.com/ -- Development & Consulting Services
 
D

Dmitry V. Sabanin

It does indeed seem like you have a problem with the after filters. Try
turning them off and see if it works then. If so, I'll be happy to take
a look at your after_filters to help you figure out what the problem is
there.
Yep, it was problem with my after filters, I fixed it with following code:

def layout_normal
@content_for_layout = response.body
saved_headers = response.headers.dup # this
render 'layouts/main'
response.headers = saved_headers # and this
true
end

Btw, big thank you and others for Rails!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,241
Latest member
Lisa1997

Latest Threads

Top