Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7551411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:29:15+00:00 2026-05-30T10:29:15+00:00

In my Rails 3 app, for some reason I’m getting a 302 in my

  • 0

In my Rails 3 app, for some reason I’m getting a 302 in my registration process. Specifically, when I redirect from creating a new User to editing their Profile I get redirected out of the app to /login. This only happens on Heroku. If I run the app locally, it works as it should.

Here’s my heroku logs:

2012-02-10T02:22:05+00:00 app[web.1]: Started POST "/users" for 98.218.231.113 at     2012-02-10 02:22:05 +0000
2012-02-10T02:22:05+00:00 app[web.1]: 
2012-02-10T02:22:05+00:00 app[web.1]: 
2012-02-10T02:22:06+00:00 app[web.1]:   Processing by UsersController#create as HTML
2012-02-10T02:22:06+00:00 app[web.1]: [paperclip] Saving attachments.
2012-02-10T02:22:06+00:00 app[web.1]: Rendered user_mailer/registration_confirmation.text.erb (0.4ms)
2012-02-10T02:22:06+00:00 app[web.1]: Completed 302 Found in 964ms
2012-02-10T02:22:06+00:00 app[web.1]: Sent mail to andy@dundermifflin.com (694ms)
2012-02-10T02:22:06+00:00 heroku[router]: POST myapp.org/users dyno=web.1 queue=0 wait=0ms service=984ms status=302 bytes=97
2012-02-10T02:22:06+00:00 app[web.1]: Redirected to http://myapp.org/signup/join
2012-02-10T02:22:06+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "authenticity_token"=>"4PjdAx5aaSph3KBDQfiPlJTlvTsh+DDTF1x+S7Ol2jc=", "user"=>{"profile_attributes"=>{"first_name"=>"Andrew", "last_name"=>"Bernard", "bio"=>""}, "email"=>"andy@dundermifflin.com", "password"=>"[FILTERED]"}, "commit"=>"Sign Up For myapp"}
2012-02-10T02:22:06+00:00 app[web.1]: Rendered user_mailer/registration_confirmation.html.erb (0.6ms)
2012-02-10T02:22:06+00:00 app[web.1]: 
2012-02-10T02:22:06+00:00 heroku[nginx]: 98.218.231.113 - - [10/Feb/    2012:02:22:06 +0000] "POST /users HTTP/1.1" 302 97 "http://myapp.org/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.53.11 (KHTML, like Gecko) Version/5.1.3 Safari/534.53.10" myapp.org
2012-02-10T02:22:06+00:00 app[web.1]: Started GET "/signup/join" for 98.218.231.113 at     2012-02-10 02:22:06 +0000
2012-02-10T02:22:06+00:00 app[web.1]: 
2012-02-10T02:22:06+00:00 app[web.1]: 
2012-02-10T02:22:06+00:00 heroku[router]: GET myapp.org/signup/join dyno=web.1 queue=0 wait=0ms service=29ms status=302 bytes=91
2012-02-10T02:22:06+00:00 app[web.1]:   Processing by ProfilesController#edit as HTML
2012-02-10T02:22:06+00:00 app[web.1]: Redirected to http://myapp.org/login
2012-02-10T02:22:06+00:00 app[web.1]: Completed 302 Found in 12ms
2012-02-10T02:22:06+00:00 heroku[nginx]: 98.218.231.113 - - [10/Feb/    2012:02:22:06 +0000] "GET /signup/join HTTP/1.1" 302 91 "http://myapp.org/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.53.11 (KHTML, like Gecko) Version/5.1.3 Safari/534.53.10" myapp.org
2012-02-10T02:22:06+00:00 app[web.1]: 
2012-02-10T02:22:06+00:00 app[web.1]: 
2012-02-10T02:22:06+00:00 app[web.1]: Started GET "/login" for 98.218.231.113 at     2012-02-10 02:22:06 +0000
2012-02-10T02:22:06+00:00 app[web.1]:   Processing by SessionsController#new as HTML
2012-02-10T02:22:06+00:00 app[web.1]: Rendered layouts/_footer.html.erb (0.6ms)
2012-02-10T02:22:06+00:00 heroku[router]: GET myapp.org/login dyno=web.1 queue=0 wait=0ms service=27ms status=200 bytes=3062

In my users_controller.rb:

def create
  @user = User.new(params[:user])
  if @user.save
    session[:user_id] = @user.id
    redirect_to join_path, :notice => 'User successfully added.'
    UserMailer.registration_confirmation(@user).deliver
  else
    render :action => 'new'
  end
end

In my routes.rb:

match "/signup/join" => "profiles#edit", :as => 'join'

So if I look at my logs, I’m submitting a POST to /users, sending an email, and redirecting to the edit action in profiles_controller.rb. So it seems like everything should be correct but I’m getting redirected. Has anyone had this happen to them too?

UPDATE: In my profiles_controller.rb:

class ProfilesController < ApplicationController
  before_filter :authenticate, :only => [:edit, :update]
  layout "application", :except => [:edit, :show]

  def user
    @user = current_user
  end

  def edit
    @profile = user.profile
    render :layout => "join_form"
  end

In my sessions_controller.rb:

class SessionsController < ApplicationController  
  def new
  end

  def create
    if user = User.authenticate(params[:email].downcase, params[:password])
      session[:user_id] = user.id
      cookies.permanent[:auth_token] = user.auth_token
      if user.profile.higher_ed?
        redirect_to user.profile, :notice => "Logged in successfully"
      else
        redirect_to join_path, :notice => "Logged in successfully"
      end
    else
      flash.now[:alert] = "Invalid login/password. Try again!"
      render :action => 'new'
    end
  end

My gemfile:

source "http://rubygems.org"
gem "aws-s3", :require => "aws/s3"
gem "aws-sdk"
gem "cancan"
gem "cocaine"
gem "fastercsv"
gem "nifty-generators"
gem "jquery-rails", ">= 1.0.12"
gem "paperclip"
gem "rails", "3.0.5"
gem "rake", "0.9.2"
gem "ransack"
gem "twitter"
gem "mocha", :group => :test
group :production, :development, :test do
  gem "pg"
end
gem "pg"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T10:29:16+00:00Added an answer on May 30, 2026 at 10:29 am

    As @phoet suggested above, I started removing code that was potentially causing issues and I got a no method error, which led me to my solution. I had to rework the logic in my current_user method. I changed it from:

    def current_user
      return unless session[:user_id]
      @current_user ||= User.find_by_id(session[:user_id])
      @current_user ||= User.find_by_auth_token!(cookies[:auth_token]) if cookies[:auth_token]
    end    
    

    To:

    def current_user
      @current_user ||= lookup_user
    end
    
    def lookup_user
      if cookies[:auth_token]
        User.find_by_auth_token!(cookies[:auth_token])
      elsif session[:user_id]
        User.find_by_id(session[:user_id])
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've recently switched over a rails app to a new server. For some reason,
I need some references for creating a Rails app where each client/company has his
I have got Sinatra/Rails app and an action which starts some long process. Ordinary
I'm creating a Rails app for students and high schools and I'm having some
I am developing an app in JRuby on Rails. For some reason, when I
I have a Rails 3.1 app and for some reason when I change CSS,
Something really weird is happening to my Rails app. For some strange reason, jQuery
I'm using devise with my rails 3 app. For some reason the sign in
For some reason I'm not getting any emails from ExceptionNotifier. I followed the instructions
I'm developing a Rails app using the rails s WEBrick server. For some reason,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.