Search code examples
ruby-on-railsrubyhttp-redirectruby-on-rails-2actioncontroller

Issue with Redirect not functioning in Rail 2


I have this redirection in the middle of my controller so if something isn't there, it will redirect you to a new area of the site if needed. Here is the problem. It is just ignoring the redirect in the code. It looks like this.

if conditions
  redirect_to "/new/address"
end

I can't even figure out why it won't redirect, but I know it makes it into the conditional and literally just ignores the redirect. What am I missing here!?

I am using Rails 2 and Ruby 1.8


Solution

  • What are you seeing? Is it raising an error? Is there an error message in the console when running "script/server"? For this to work, there should be something to handle the path "new", typically a controller called "NewsController" (plural form) or some rule in the routes.rb file.

    If you are seeking to create a new address, then you may be looking for something like

    if conditions
       redirect_to new_address_path
    end